Example #1
0
        public DataView LoadDecoupledView(Type recType, Func <MappedRecord, bool> where)
        {
            DataView      dv = CreateDecoupledView(recType);
            SqlConnection connection;
            DataContext   newContext;

            ContextExtensionMethods.CreateNewContext(context, out connection, out newContext);
            newContext.GetTable(recType.Name).Where(where).ForEach(m => AppendDecoupledRow(dv, recType, m));

            return(dv);
        }
Example #2
0
        /// <summary>
        /// Loads all the records for the model type into the DataView and our underlying model collection for that model type.
        /// </summary>
        public List <IEntity> LoadRecords <T>(DataView dv, Expression <Func <T, bool> > whereClause = null) where T : MappedRecord, IEntity
        {
            Clear <T>();
            Type          recType = typeof(T);
            SqlConnection connection;
            DataContext   newContext;

            ContextExtensionMethods.CreateNewContext(context, out connection, out newContext);
            newContext.Query(whereClause).ForEach(m => AppendRow(dv, m));

            return(mappedRecords[recType]);
        }
Example #3
0
        public DataView LoadDecoupledView(Type recType, out List <IEntity> records)
        {
            DataView      dv = CreateDecoupledView(recType);
            SqlConnection connection;
            DataContext   newContext;

            ContextExtensionMethods.CreateNewContext(context, out connection, out newContext);
            var mappedRecords = newContext.GetTable(recType.Name);

            records = mappedRecords.Cast <IEntity>().ToList();
            mappedRecords.ForEach(m => AppendDecoupledRow(dv, recType, m));

            return(dv);
        }
Example #4
0
        public List <IEntity> LoadRecords(Type recType, DataView dv, Func <MappedRecord, bool> where)
        {
            Clear(recType);
            // We create a new context because the existing context caches the previously queried model.
            SqlConnection connection;
            DataContext   newContext;

            ContextExtensionMethods.CreateNewContext(context, out connection, out newContext);
            var records = newContext.GetTable(recType.Name).Where(where);

            records.ForEach(m => AppendDecoupledRow(dv, recType, m));
            // newContext.Dispose();

            return(records.Cast <IEntity>().ToList());
        }