Ejemplo n.º 1
0
 private Criteria(Mapping.Table table, IConnection connection, IConnectionFactorySupport factory)
 {
     _table        = table;
     _connection   = connection;
     _factory      = factory;
     Parameterized = true;
     Total         = -1;
     Offset        = 0;
 }
Ejemplo n.º 2
0
 private Criteria(Mapping.Table table, IConnection connection, IConnectionFactorySupport factory)
 {
     _table = table;
     _connection = connection;
     _factory = factory;
     Parameterized = true;
     Total = -1;
     Offset = 0;
 }
Ejemplo n.º 3
0
        static Func <IDataReader, Object> GetObjectDeserializer(Type type, IConnectionFactorySupport factory)
        {
            return(delegate(IDataReader reader)
            {
                Object obj = null;
                var fieldCount = reader.FieldCount;

                if (type.IsPrimitive)
                {
                    // If the type is a primitive type, takes only the first column as the result.
                    if (fieldCount > 0)
                    {
                        obj = Convert.ChangeType(reader.GetValue(0), type);
                    }
                }
                else
                {
                    Mapping.Table table = factory.Mapping.FindTable(type);
                    obj = Activator.CreateInstance(type);
                    for (var i = 0; i < fieldCount; i++)
                    {
                        var tmp = reader.GetValue(i);
                        if (tmp == DBNull.Value)
                        {
                            continue;
                        }
                        Mapping.Column column = table.FindColumnByColumnName(reader.GetName(i));
                        if (column != null)
                        {
                            PropertyInfo pi = (column.MemberInfo == null || column.MemberInfo.Property == null) ? type.GetProperty(column.FieldName) : column.MemberInfo.Property;
                            pi.SetValue(obj, System.Convert.ChangeType(tmp, pi.PropertyType), null);
                        }
                    }
                }

                return obj;
            });
        }
Ejemplo n.º 4
0
 public Criteria(String entity, IConnection connection, IConnectionFactorySupport factory)
     : this(factory.Mapping.FindTable(entity), connection, factory)
 {
     _entity = entity;
 }
Ejemplo n.º 5
0
 public Criteria(Type type, IConnection connection, IConnectionFactorySupport factory)
     : this(factory.Mapping.FindTable(type), connection, factory)
 {
     _type = type;
 }
Ejemplo n.º 6
0
 private static IEnumerable <IDictionary <String, Object> > QueryInternal(Mapping.Table table, System.Data.IDbConnection connection, String sql, Object param, IDbTransaction transaction, CommandType?commandType, Int32?commandTimeout, IConnectionFactorySupport factory)
 {
     return(QueryInternal <IDictionary <String, Object> >(mapType, table, connection, sql, param, transaction, commandType, commandTimeout));
 }
Ejemplo n.º 7
0
 private static IEnumerable QueryInternal(Type type, System.Data.IDbConnection connection, String sql, Object param, IDbTransaction transaction, CommandType?commandType, Int32?commandTimeout, IConnectionFactorySupport factory)
 {
     return(QueryInternal(type == null ? mapType : type, type == null ? null : factory.Mapping.FindTable(type), connection, sql, param, transaction, commandType, commandTimeout));
 }
Ejemplo n.º 8
0
        private static IEnumerable <T> QueryInternal <T>(System.Data.IDbConnection connection, String sql, Object param, IDbTransaction transaction, CommandType?commandType, Int32?commandTimeout, IConnectionFactorySupport factory)
        {
            Type type = typeof(T);

            return(QueryInternal <T>(type, factory.Mapping.FindTable(type), connection, sql, param, transaction, commandType, commandTimeout));
        }
Ejemplo n.º 9
0
 public Criteria(String entity, IConnection connection, IConnectionFactorySupport factory)
     : this(factory.Mapping.FindTable(entity), connection, factory)
 {
     _entity = entity;
 }
Ejemplo n.º 10
0
 public Criteria(Type type, IConnection connection, IConnectionFactorySupport factory)
     : this(factory.Mapping.FindTable(type), connection, factory)
 {
     _type = type;
 }