Exemplo n.º 1
0
 /// <summary>
 /// Loads instances of <typeparamref name="TModel"/>.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="query"></param>
 /// <param name="provider"></param>
 /// <param name="transactionContext"></param>
 /// <returns></returns>
 public static DataModelCollection <TModel> LoadMany <TModel>(DataModelQuery <TModel> query,
                                                              DataProviderBase provider,
                                                              DbTransaction transactionContext)
     where TModel : DataModel
 {
     return(LoadMany(query, false, provider, transactionContext));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Loads an instance of <typeparamref name="TModel"/>.
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="query"></param>
        /// <param name="depth"></param>
        /// <param name="provider"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public static TModel Load <TModel>(DataModelQuery <TModel> query, int?depth, DataProviderBase provider,
                                           DbTransaction transactionContext) where TModel : DataModel
        {
            TModel ret = depth.HasValue
                             ? provider.DeepLoadModel(query, depth, transactionContext)
                             : provider.DeepLoadModel(query, transactionContext);

            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads instances of <typeparamref name="TModel"/>.
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="query"></param>
        /// <param name="depth"></param>
        /// <param name="provider"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public static DataModelCollection <TModel> LoadMany <TModel>(DataModelQuery <TModel> query, int?depth,
                                                                     DataProviderBase provider,
                                                                     DbTransaction transactionContext)
            where TModel : DataModel
        {
            DataModelCollection <TModel> ret = depth.HasValue
                ? provider.DeepLoadModels(query, depth, transactionContext)
                : provider.DeepLoadModels(query, transactionContext);

            return(ret);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Clears out the internal reference to the originating <see cref="DataModelQuery"/>
        /// to remove the circular reference
        /// and then returns that Query to the caller.
        /// </summary>
        /// <returns></returns>
        protected virtual DataModelQuery <TModel> NullifyAndReturnQuery()
        {
            var q = _returnQuery;

            if (q == null)
            {
                return(null);
            }
            _returnQuery = null;
            q.Conditions.Add(this);
            return(q);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Loads an instance of <typeparamref name="TModel"/>.
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="query"></param>
        /// <param name="deep"></param>
        /// <param name="provider"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public static TModel Load <TModel>(DataModelQuery <TModel> query, bool deep, DataProviderBase provider,
                                           DbTransaction transactionContext) where TModel : DataModel
        {
            if (provider == null)
            {
                provider = ProviderDefaults.AppProvider;
            }
            if (deep)
            {
                return(Load(query, null, provider, transactionContext));
            }
            TModel ret = provider.LoadModel(query, transactionContext);

            return(ret);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Loads an instance of <see cref="DataModel{TEntity}"/>.
        /// </summary>
        /// <param name="query"></param>
        /// <param name="deep"></param>
        /// <param name="provider"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public static DataModelCollection <DataModel <TEntity> > LoadMany(DataModelQuery <DataModel <TEntity> > query, bool deep,
                                                                          DataProviderBase provider, DbTransaction transactionContext)
        {
            if (provider == null)
            {
                provider = ProviderDefaults.AppProvider;
            }
            if (deep)
            {
                return(LoadMany(query, null, provider, transactionContext));
            }
            var col = provider.LoadModels(query, transactionContext);
            var ret = new DataModelCollection <DataModel <TEntity> >(col);

            return(ret);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Loads an instance of <see cref="DataModel{TEntity}"/>.
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="query"></param>
        /// <param name="depth"></param>
        /// <param name="provider"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public new static DataModel <TEntity> Load <TModel>(DataModelQuery <TModel> query, int?depth,
                                                            DataProviderBase provider, DbTransaction transactionContext)
            where TModel : DataModel <TEntity>
        {
            TModel ret;

            if (depth.HasValue)
            {
                ret = provider.DeepLoadModel(query, depth, transactionContext);
            }
            else
            {
                ret = provider.DeepLoadModel(query, transactionContext);
            }
            return(ret);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Loads an instance of <see cref="DataModel{TEntity}"/>.
        /// </summary>
        /// <param name="query"></param>
        /// <param name="depth"></param>
        /// <param name="provider"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public static DataModelCollection <DataModel <TEntity> > LoadMany(DataModelQuery <DataModel <TEntity> > query, int?depth,
                                                                          DataProviderBase provider, DbTransaction transactionContext)
        {
            DataModelCollection <DataModel <TEntity> > col;

            if (depth.HasValue)
            {
                col = provider.DeepLoadModels(query, depth, transactionContext);
            }
            else
            {
                col = provider.DeepLoadModels(query, transactionContext);
            }
            var ret = new DataModelCollection <DataModel <TEntity> >(col);

            return(ret);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Loads an instance of <see cref="DataModel{TEntity}"/>.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="query"></param>
 /// <param name="provider"></param>
 /// <param name="transactionContext"></param>
 /// <returns></returns>
 public new static DataModel <TEntity> Load <TModel>(DataModelQuery <TModel> query, DataProviderBase provider,
                                                     DbTransaction transactionContext)
     where TModel : DataModel <TEntity>
 {
     return(Load(query, false, provider, transactionContext));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Loads an instance of <see cref="DataModel{TEntity}"/>.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="query"></param>
 /// <param name="deep"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public new static DataModel <TEntity> Load <TModel>(DataModelQuery <TModel> query, bool deep,
                                                     DataProviderBase provider) where TModel : DataModel <TEntity>
 {
     return(Load(query, deep, provider, null));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Loads an instance of <typeparamref name="TModel"/>.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="query"></param>
 /// <param name="provider"></param>
 /// <param name="transactionContext"></param>
 /// <returns></returns>
 public static TModel Load <TModel>(DataModelQuery <TModel> query, DataProviderBase provider,
                                    DbTransaction transactionContext) where TModel : DataModel
 {
     return(Load(query, false, provider, transactionContext));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Loads an instance of <see cref="DataModel{TEntity}"/>.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="deep"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static DataModelCollection <DataModel <TEntity> > LoadMany(DataModelQuery <DataModel <TEntity> > query, bool deep,
                                                                   DataProviderBase provider)
 {
     return(LoadMany(query, deep, provider, null));
 }
Exemplo n.º 13
0
        /// <summary>
        /// Loads all instances of <see cref="DataModel{TEntity}"/>.
        /// </summary>
        /// <param name="deep"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public static DataModelCollection <DataModel <TEntity> > LoadAll(bool deep, DbTransaction transactionContext)
        {
            var query = new DataModelQuery <DataModel <TEntity> >();

            return(query.SelectMany(deep, transactionContext));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Loads all instances of <see cref="DataModel{TEntity}"/>.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public static DataModelCollection <DataModel <TEntity> > LoadAll(DbDataProvider provider, DbTransaction transactionContext)
        {
            var query = new DataModelQuery <DataModel <TEntity> >();

            return(query.SelectMany(provider, transactionContext));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Loads all instances of <typeparamref name="TModel"/>.
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="deep"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public static DataModelCollection <TModel> LoadAll <TModel>(bool deep, DbTransaction transactionContext) where TModel : DataModel
        {
            var query = new DataModelQuery <TModel>();

            return(query.SelectMany(deep, transactionContext));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Loads all instances of <typeparamref name="TModel"/>.
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="deep"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static DataModelCollection <TModel> LoadAll <TModel>(bool deep, DbDataProvider provider) where TModel : DataModel
        {
            var query = new DataModelQuery <TModel>();

            return(query.SelectMany(deep, provider));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Loads all instances of <typeparamref name="TModel"/>.
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="provider"></param>
        /// <param name="transactionContext"></param>
        /// <returns></returns>
        public static DataModelCollection <TModel> LoadAll <TModel>(DbDataProvider provider, DbTransaction transactionContext) where TModel : DataModel
        {
            var query = new DataModelQuery <TModel>();

            return(query.SelectMany(provider, transactionContext));
        }
Exemplo n.º 18
0
        /// <summary>
        /// Loads all instances of <typeparamref name="TModel"/>.
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <returns></returns>
        public static DataModelCollection <TModel> LoadAll <TModel>() where TModel : DataModel
        {
            var query = new DataModelQuery <TModel>();

            return(query.SelectMany());
        }
Exemplo n.º 19
0
 /// <summary>
 /// Loads an instance of <typeparamref name="TModel"/>.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="query"></param>
 /// <returns></returns>
 public static TModel Load <TModel>(DataModelQuery <TModel> query) where TModel : DataModel
 {
     return(Load(query, false, null, null));
 }
Exemplo n.º 20
0
        /// <summary>
        /// Loads all instances of <see cref="DataModel{TEntity}"/>.
        /// </summary>
        /// <returns></returns>
        public static DataModelCollection <DataModel <TEntity> > LoadAll()
        {
            var query = new DataModelQuery <DataModel <TEntity> >();

            return(query.SelectMany());
        }
Exemplo n.º 21
0
 /// <summary>
 /// Loads instances of <typeparamref name="TModel"/>.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="query"></param>
 /// <returns></returns>
 public static DataModelCollection <TModel> LoadMany <TModel>(DataModelQuery <TModel> query)
     where TModel : DataModel
 {
     return(LoadMany(query, false, null, null));
 }
Exemplo n.º 22
0
        /// <summary>
        /// Loads all instances of <see cref="DataModel{TEntity}"/>.
        /// </summary>
        /// <param name="deep"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static DataModelCollection <DataModel <TEntity> > LoadAll(bool deep, DbDataProvider provider)
        {
            var query = new DataModelQuery <DataModel <TEntity> >();

            return(query.SelectMany(deep, provider));
        }
Exemplo n.º 23
0
 /// <summary>
 /// Loads instances of <typeparamref name="TModel"/>.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="query"></param>
 /// <param name="deep"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static DataModelCollection <TModel> LoadMany <TModel>(DataModelQuery <TModel> query, bool deep,
                                                              DataProviderBase provider) where TModel : DataModel
 {
     return(LoadMany(query, deep, provider, null));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Loads an instance of <see cref="DataModel{TEntity}"/>.
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public static DataModelCollection <DataModel <TEntity> > LoadMany(DataModelQuery <DataModel <TEntity> > query)
 {
     return(LoadMany(query, false, null, null));
 }
Exemplo n.º 25
0
        /// <summary>
        /// Constructs a QueryCondition&lt;T&gt; object using the specified
        /// parameters for describing the nature and for binding to the query.
        /// </summary>
        /// <param name="mapBy"></param>
        /// <param name="query"></param>
// ReSharper disable SuggestBaseTypeForParameter
        public DataModelQueryCondition(FieldMappingKeyType mapBy, DataModelQuery <TModel> query)
// ReSharper restore SuggestBaseTypeForParameter
        {
            _returnQuery       = query;
            FindFieldMappingBy = mapBy;
        }
Exemplo n.º 26
0
 /// <summary>
 /// Loads an instance of <see cref="DataModel{TEntity}"/>.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="provider"></param>
 /// <param name="transactionContext"></param>
 /// <returns></returns>
 public static DataModelCollection <DataModel <TEntity> > LoadMany(DataModelQuery <DataModel <TEntity> > query, DataProviderBase provider,
                                                                   DbTransaction transactionContext)
 {
     return(LoadMany(query, false, provider, transactionContext));
 }
Exemplo n.º 27
0
 /// <summary>
 /// This is a syntactical sugar constructor.
 /// Used for chaining, allows <see cref="OfItemsPerPage"/> to
 /// return the query after the items count has been specified,
 /// while also setting the page number.
 /// </summary>
 /// <param name="query"></param>
 public QueryPagination(DataModelQuery <TModel> query)
 {
     _query = query;
 }
Exemplo n.º 28
0
 /// <summary>
 /// Loads an instance of <see cref="DataModel{TEntity}"/>.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="query"></param>
 /// <returns></returns>
 public new static DataModel <TEntity> Load <TModel>(DataModelQuery <TModel> query)
     where TModel : DataModel <TEntity>
 {
     return(Load(query, false, null, null));
 }
Exemplo n.º 29
0
 /// <summary>
 /// Loads an instance of <typeparamref name="TModel"/>.
 /// </summary>
 /// <typeparam name="TModel"></typeparam>
 /// <param name="query"></param>
 /// <param name="deep"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static TModel Load <TModel>(DataModelQuery <TModel> query, bool deep, DataProviderBase provider)
     where TModel : DataModel
 {
     return(Load(query, deep, provider, null));
 }