src/WeText.Common/Querying/TableDataGateway.cs
/// <summary>
/// Creates the data object instance from a <see cref="System.Data.Common.DbDataReader"/> instance.
/// </summary>
/// <typeparam name="TTableObject">The type of the object to be created.</typeparam>
/// <param name="reader">The <see cref="System.Data.Common.DbDataReader"/> instance.</param>
/// <returns>The data object instance.</returns>
Creates the data object instance from a  instance.
Creates the data object instance from a instance .
protected virtual TTableObject CreateFromReader<TTableObject>(DbDataReader reader)
            where TTableObject : class, new()
        {
            TTableObject t = new TTableObject();
            typeof(TTableObject)
                .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.SetProperty)
                .ToList()
                .ForEach(pi =>
                {
                    var value = reader[pi.Name];
                    if (value != DBNull.Value)
                    {
                        if (pi.PropertyType == typeof(Guid))
                            pi.SetValue(t, new Guid(Convert.ToString(reader[pi.Name])), null);
                        else
                            pi.SetValue(t, reader[pi.Name], null);
                    }
                });
            return t;
        }
protected virtual TTableObject CreateFromReader < TTableObject > ( DbDataReader reader ) where TTableObject : class , new ( ) { TTableObject t = new TTableObject ( ) ; typeof ( TTableObject ) . GetProperties ( BindingFlags . Public | BindingFlags . Instance | BindingFlags . GetProperty | BindingFlags . SetProperty ) . ToList ( ) . ForEach ( pi => { var value = reader [ pi . Name ] ; if ( value != DBNull . Value ) { if ( pi . PropertyType == typeof ( Guid ) ) pi . SetValue ( t , new Guid ( Convert . ToString ( reader [ pi . Name ] ) ) , null ) ; else pi . SetValue ( t , reader [ pi . Name ] , null ) ; } } ) ; return t ; }
Creates the data object instance from a  instance.
Creates the data object instance from a instance .
The data object instance.
The data object instance .
reader
DbDataReader
None
typeparam
The type of the object to be created.
The type of the object to be created .