public DbContainer(List <DbObject <T> > dbObjects , DataContext tableContext, DataGateORM orm) { _dbObjects = dbObjects; TableContext = tableContext; _orm = orm; }
//TODO: Entity caching public IEnumerable<DbObject<T>> ToDbObjects<T>(DataContext dataContext, DataGateORM orm) { foreach (var row in dataContext) { var obj = Activator.CreateInstance(EntityType); foreach (var variable in _variables) { var memberInfo = variable.MemberInfo; var dbIdentifier = GetDbIdentifier(memberInfo); var value = row.Value[dbIdentifier].Value; //TODO: resolve Nullable type try { object parsedValue = Convert.ChangeType(value, variable.VariableType); variable[obj] = parsedValue; } catch { //ignore } } var dbObj = new DbObject<T>((T) obj, row.Value, (int) (row.Value["datagate_id"]?.Value ?? -1), orm); yield return dbObj; } }
public DbObject(T value, DataContext rowContext , int dataGateId, DataGateORM orm) { Value = value; RowContext = rowContext; DataGateId = dataGateId; _orm = orm; }
public QueryBuilder(DataGateORM orm) { if (!DataGateORM.ConnectionContext.Registry.Contains <TOut>()) { throw new Exception($"Type '{typeof(TOut)}' is not registered in ORM"); } _orm = orm; _fromParams = new HashSet <Type>(); _fromParams.Add(typeof(TIn)); _offset = null; _limit = null; _orderByExpressions = new List <Tuple <Expression, OrderByType> >(); _joinExpressions = new List <Tuple <Expression, Type> >(); }