private Criteria(Mapping.Table table, IConnection connection, IConnectionFactorySupport factory) { _table = table; _connection = connection; _factory = factory; Parameterized = true; Total = -1; Offset = 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; }); }
public Criteria(String entity, IConnection connection, IConnectionFactorySupport factory) : this(factory.Mapping.FindTable(entity), connection, factory) { _entity = entity; }
public Criteria(Type type, IConnection connection, IConnectionFactorySupport factory) : this(factory.Mapping.FindTable(type), connection, factory) { _type = type; }
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)); }
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)); }
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)); }