コード例 #1
0
        /// <summary>
        /// Return full list of entities from Db table
        /// </summary>
        public virtual IQueryable <EntityType> GetAll(string navigationalProperties = "")
        {
            IQueryable <EntityType> _retData;
            var navPropertiesList = navigationalProperties.Split(",".ToCharArray());

            try
            {
                if (String.IsNullOrEmpty(navigationalProperties))
                {
                    _retData = _dbContext.Set <EntityType>();
                }
                else
                {
                    var dbQuery = _dbContext.Set <EntityType>().Include(navPropertiesList[0]);
                    for (int i = 1; i < navPropertiesList.Length; i++)
                    {
                        dbQuery.Include(navPropertiesList[i]);
                    }
                    _retData = dbQuery;
                }
            }
            catch (Exception ex)
            {
                _retData = null;
            }

            return(_retData.OrderBy(x => x.CreatedAt));
        }
コード例 #2
0
 public GenericRepository(WfpictContext context)
 {
     this._context = context;
     this._dbSet   = context.Set <TEntity>();
 }