public List <Config> List()
        {
            System.Linq.IQueryable <Config> Return = from Table in this.DBLocal.Config
                                                     select Table;

            return(Return.ToList());
        }
Exemple #2
0
        /// <summary>
        /// 对第一条记录开启更新锁,并返回这条记录的对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="items"></param>
        /// <returns></returns>
        public T UpdateLockFirstOrDefault <T>(System.Linq.IQueryable <T> items) where T : class
        {
            if (this.Database.Connection.State != System.Data.ConnectionState.Open)
            {
                throw new Exception("没有开启事务");
            }

            Type dataType = typeof(T);

            var tableSchema = SchemaManager.GetSchemaTable(dataType);

            if (tableSchema.KeyColumn == null)
            {
                throw new Exception(dataType.Name + "没有定义主键");
            }

            var query   = InvokeSelect(items, tableSchema.KeyColumn.PropertyName);
            var idvalue = InvokeFirstOrDefault(query);

            if (idvalue == null)
            {
                return(default(T));
            }

            this.Database.UpdateLock(dataType, idvalue);

            query = this.Set <T>();
            query = InvokeWhereEquals(query, tableSchema.KeyColumn.PropertyName, idvalue);
            return((T)InvokeFirstOrDefault(query));
        }
        public List <PsProductAttachment> List()
        {
            System.Linq.IQueryable <PsProductAttachment> Return = from Table in this.DBPrestashop.PsProductAttachment
                                                                  select Table;

            return(Return.ToList());
        }
Exemple #4
0
        public List <AttributeArticle> List()
        {
            System.Linq.IQueryable <AttributeArticle> Return = from Table in this.DBLocal.AttributeArticle
                                                               select Table;

            return(Return.ToList());
        }
Exemple #5
0
        /**/

        /// <summary>
        /// 创建自身实例
        /// </summary>
        /// <typeparam name="N">类型,如果此处为匿名类型,请用var 定义实体,且类后的T为object(其实什么也不重要,只是用于可以调用当前类的静态方法)</typeparam>
        /// <param name="Query">Linq查询语句</param>
        /// <param name="type">元素类型</param>
        /// <param name="IndexPage">开始页</param>
        /// <param name="PageSize">每页大小</param>
        /// <returns></returns>
        public static DataPageList <N> Create <N>(System.Linq.IQueryable Query, int IndexPage, int PageSize)
        {
            System.Linq.IQueryable <N> query = (System.Linq.IQueryable <N>)Query;
            return(new DataPageList <N>(query, IndexPage, PageSize));
        }

        //public static DataPageList<N> Create<N>(System.Linq.IQueryable Query, int IndexPage, int PageSize)
        //{
        //    return Create<N>(Query, IndexPage, PageSize);
        //}

        /**/

        /// <summary>
        /// 更新数据
        /// </summary>
        public virtual void Update()
        {
            allRecordCount = query.Count();
            PageAttrList.Clear();
            if (pageSize > 0)
            {
                query = query.Skip((indexPage - 1) * pageSize).Take(pageSize);
                thisPageRecordCount = query.Count();
                //计算分页结果
                pageCount = (allRecordCount % pageSize == 0) ? (allRecordCount / pageSize) : allRecordCount / pageSize + 1;
                if (indexPage > 1)
                {
                    canFirstPage = true;
                }
                canPrevPage = true;
                if (indexPage < pageCount)
                {
                    canNextPage = true;
                }
                canLastpage = true;
            }
            else
            {
                thisPageRecordCount = allRecordCount;
                pageCount           = indexPage = 1;
                canFirstPage        = canPrevPage = canNextPage = canLastpage = false;
            }
            for (var cur = 1; cur <= pageCount; cur++)
            {
                PageAttrList.Add(new PageAttr {
                    Page = cur
                });
            }
            listValue = query.ToList();
        }
        public List <PsOrderHistory> List()
        {
            System.Linq.IQueryable <PsOrderHistory> Return = from Table in this.DBPrestashop.PsOrderHistory
                                                             select Table;

            return(Return.ToList());
        }
Exemple #7
0
        public static System.Linq.IQueryable <TEntity> Contains <TEntity, T>(this System.Linq.IQueryable <TEntity> source,
                                                                             IEnumerable <T> forCollection, string fullyQualifiedTableName, bool avoidReadLocks = false,
                                                                             params Expression <Func <TEntity, object> >[] joinColumns
                                                                             )
            where TEntity : class

        {
            var root = new XElement("nodes");

            //generate xml
            foreach (var entity in forCollection)
            {
                root.Add(new XElement("node",
                                      joinColumns.Select(c => new XElement(ExtensionHelper.GetProperty(c).Name,
                                                                           entity.GetType().GetProperty(ExtensionHelper.GetProperty(c).Name)?.GetValue(entity, null)))));
            }

            var sqlStr =
                new StringBuilder(
                    $"SELECT tbl.* FROM @xml.nodes('/nodes/node') nodes([node]) JOIN {fullyQualifiedTableName} tbl {(avoidReadLocks ? "WITH (NOLOCK)" : "")} ON ");

            //append join filter clauses
            sqlStr.Append(string.Join(" AND ",
                                      joinColumns.Select(c =>
                                                         $"tbl.[{ExtensionHelper.GetProperty(c).Name}] = [nodes].[node].value('({ExtensionHelper.GetProperty(c).Name})[1]', '{ExtensionHelper.GetDbMappedType(ExtensionHelper.GetProperty(c).GetUnderlyingType())}')")));

            var matched = source.FromSql(sqlStr.ToString(), new SqlParameter("@xml", new SqlXml(root.CreateReader())));

            return(matched.AsQueryable());
        }
        public List <PsProductAttributeCombination> List()
        {
            System.Linq.IQueryable <PsProductAttributeCombination> Return = from Table in this.DBPrestashop.PsProductAttributeCombination
                                                                            select Table;

            return(Return.ToList());
        }
        public List <Settlement> List()
        {
            System.Linq.IQueryable <Settlement> Return = from Table in this.DBLocal.Settlement
                                                         select Table;

            return(Return.ToList());
        }
Exemple #10
0
        //-------------------------------------------------------------------------------------------------

        public IEnumerable <UserForShowDto> FilterSerchingUsers(FilterUserRequestDto searchItem)
        {
            IEnumerable <UserForShowDto> res = null;

            using (_db = new IdeaManagmentDatabaseEntities())
            {
                System.Linq.IQueryable <USER> users = _db.USERS;
                if (searchItem.Username != null && searchItem.Username.Trim().Length > 0)
                {
                    users = users.Where(u => u.USERNAME.Contains(searchItem.Username.Trim()));
                }
                if (searchItem.FullName != null && searchItem.FullName.Trim().Length > 0)
                {
                    if (searchItem.FullName.Trim().Contains(" "))
                    {
                        var firstName = searchItem.FullName.Trim().Substring(0, searchItem.FullName.Trim().IndexOf(" "));
                        var lastName  = searchItem.FullName.Trim().Substring(searchItem.FullName.Trim().IndexOf(" ") + 1);
                        users = users.Where(u => u.FIRST_NAME.Contains(firstName.Trim()) && u.LAST_NAME.Contains(lastName.Trim()));
                    }
                    else
                    {
                        users = users.Where(u => u.FIRST_NAME.Contains(searchItem.FullName.Trim()) || u.LAST_NAME.Contains(searchItem.FullName.Trim()));
                    }
                }
                switch (searchItem.RoleValue)
                {
                case 0:
                    users = users.Where(u => u.ADMIN_FLAG == false && u.COMMITTEE_FLAG == false);
                    break;

                case 1:
                    users = users.Where(u => u.ADMIN_FLAG == false && u.COMMITTEE_FLAG == true);

                    break;

                case 2:
                    users = users.Where(u => u.ADMIN_FLAG == true && u.COMMITTEE_FLAG == false);

                    break;

                case 3:
                    users = users.Where(u => u.ADMIN_FLAG == true && u.COMMITTEE_FLAG == true);
                    break;

                default:
                    break;
                }
                res = users.ToList().Select(x => new UserForShowDto()
                {
                    CommitteFlag = x.COMMITTEE_FLAG,
                    AdminFlag    = x.ADMIN_FLAG,
                    Email        = x.EMAIL,
                    FirstName    = x.FIRST_NAME,
                    LastName     = x.LAST_NAME,
                    SaveDate     = Persia.Calendar.ConvertToPersian(x.SAVE_DATE).Simple,
                    Username     = x.USERNAME
                });
            }
            return(res);
        }
Exemple #11
0
        public static int GetCountFromCache <T>(this System.Linq.IQueryable <T> q, System.Data.Linq.DataContext dc)
        {
            try
            {
                string CacheId = q.ToString() + "Count?";
                foreach (System.Data.Common.DbParameter dbp in dc.GetCommand(q).Parameters)
                {
                    CacheId += dbp.ParameterName + "=" + dbp.Value.ToString() + "&";
                }
                object count;
                //if (Environment.StackTrace.Contains("CMS\\"))
                //{
                count = q.Count();
                return((int)count);

                //}
                //else
                //{
                //System.Threading.Thread.Sleep(500);
                count = System.Web.HttpRuntime.Cache.Get(CacheId);
                // }
                if (count == null)
                {
                    List <string> tablesNames = dc.Mapping.GetTables().Where(t => CacheId.Contains("[" + t.TableName.Substring(4) + "]")).Select(t => t.TableName.Substring(4)).ToList();
                    string        connStr     = dc.Connection.ConnectionString;
                    using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connStr))
                    {
                        conn.Open();
                        System.Web.Caching.SqlCacheDependencyAdmin.EnableNotifications(connStr);
                        System.Web.Caching.SqlCacheDependency sqldep;
                        AggregateCacheDependency aggDep = new AggregateCacheDependency();
                        foreach (string tableName in tablesNames)
                        {
                            if (!System.Web.Caching.SqlCacheDependencyAdmin.GetTablesEnabledForNotifications(connStr).Contains(tableName))
                            {
                                System.Web.Caching.SqlCacheDependencyAdmin.EnableTableForNotifications(connStr, tableName);
                            }
                            if (tableName.Contains("Comment") || tableName.Contains("PollDetail"))
                            {
                                sqldep = new System.Web.Caching.SqlCacheDependency("PlatformCacheSmallPollTime", tableName);
                            }
                            else
                            {
                                sqldep = new System.Web.Caching.SqlCacheDependency("PlatformCache", tableName);
                            }
                            aggDep.Add(sqldep);
                        }

                        count = q.Count();
                        System.Web.HttpRuntime.Cache.Insert(CacheId, count, aggDep, DateTime.Now.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration);
                    }
                }
                //Return the created (or cached) List
                return((int)count);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
        public List <PsOleaPromo> List()
        {
            System.Linq.IQueryable <PsOleaPromo> Return = from Table in this.DBPrestashop.PsOleaPromo
                                                          select Table;

            return(Return.ToList());
        }
Exemple #13
0
 public List<PsOrderCartRule> ListOrder(UInt32 Order)
 {
     System.Linq.IQueryable<PsOrderCartRule> Return = from Table in this.DBPrestashop.PsOrderCartRule
                                                            where Table.IDOrder == Order
                                                            select Table;
     return Return.ToList();
 }
Exemple #14
0
        public List <Group> List()
        {
            System.Linq.IQueryable <Group> Return = from Table in this.DBLocal.Group
                                                    select Table;

            return(Return.ToList());
        }
        public List <Order> List()
        {
            System.Linq.IQueryable <Order> Return = from Table in this.DBLocal.Order
                                                    select Table;

            return(Return.ToList());
        }
Exemple #16
0
        public List <PsConfiguration> List()
        {
            System.Linq.IQueryable <PsConfiguration> Return = from Table in this.DBPrestashop.PsConfiguration
                                                              select Table;

            return(Return.ToList());
        }
Exemple #17
0
        private void Filter()
        {
            System.Linq.IQueryable <vQuestionX> q = from p in db.vQuestionXes select p;

            if (GlobalClass.checkUserStatus() != 1)
            {
                q = from p in db.vQuestionXes where p.User_Name.Equals(GlobalClass.UserName) select p;
            }

            if (this.TxtQuestionNumber.Text != "")
            {
                q = from p in q where p.Question_Number.Equals(Convert.ToInt32(this.TxtQuestionNumber.Text)) select p;
            }
            if (this.cboCourt.SelectedIndex != -1)
            {
                q = from p in q where p.Court_ID.Equals(Convert.ToInt32(this.cboCourt.SelectedValue)) select p;
            }
            if (this.cboDateInterval.SelectedIndex != -1)
            {
                q = from p in q where p.Date_Interval_ID.Equals(Convert.ToInt32(this.cboDateInterval.SelectedValue)) select p;
            }
            if (this.cboGender.SelectedIndex != -1)
            {
                q = from p in q where p.Gender_ID.Equals(Convert.ToInt32(this.cboGender.SelectedValue)) select p;
            }
            if (this.cboRecordStatus.SelectedIndex != -1)
            {
                q = from p in q where p.Record_Status_ID.Equals(Convert.ToInt32(this.cboRecordStatus.SelectedValue)) select p;
            }

            this.vQuestionXBindingSource.DataSource = q;
        }
Exemple #18
0
        public List <ConditioningArticle> List()
        {
            System.Linq.IQueryable <ConditioningArticle> Return = from Table in this.DBLocal.ConditioningArticle
                                                                  select Table;

            return(Return.ToList());
        }
        public List <PsCategoryGroup> List()
        {
            System.Linq.IQueryable <PsCategoryGroup> Return = from Table in this.DBPrestashop.PsCategoryGroup
                                                              select Table;

            return(Return.ToList());
        }
        public List <Supply> List()
        {
            System.Linq.IQueryable <Supply> Return = from Table in this.DBLocal.Supply
                                                     select Table;

            return(Return.ToList());
        }
Exemple #21
0
        public List <CompositionArticleImage> List()
        {
            System.Linq.IQueryable <CompositionArticleImage> Return = from Table in this.DBLocal.CompositionArticleImage
                                                                      select Table;

            return(Return.ToList());
        }
        public List <CatalogImage> List()
        {
            System.Linq.IQueryable <CatalogImage> Return = from Table in this.DBLocal.CatalogImage
                                                           select Table;

            return(Return.ToList());
        }
Exemple #23
0
        public List <Tax> List()
        {
            System.Linq.IQueryable <Tax> Return = from Table in this.DBLocal.Tax
                                                  select Table;

            return(Return.ToList());
        }
Exemple #24
0
        public List <Model.Internal.CategorieComptable> ListCatComptaVente()
        {
            List <Model.Internal.CategorieComptable> Return = new List <Model.Internal.CategorieComptable>();

            System.Linq.IQueryable <P_CATCOMPTA> List       = this.DBSage.P_CATCOMPTA;
            System.Reflection.PropertyInfo[]     Properties = List.ToList()[0].GetType().GetProperties();
            foreach (System.Reflection.PropertyInfo Property in Properties)
            {
                if (Property.GetValue(List.ToList()[0], null).ToString() != "" &&
                    Property.Name != "cbMarq" &&
                    Property.Name.Contains("Ven"))
                {
                    string Marq = Property.Name.Split(new String[] { "Ven" }, StringSplitOptions.None)[1];
                    if (Core.Global.IsInteger(Marq))
                    {
                        Return.Add(new Model.Internal.CategorieComptable()
                        {
                            SageMarq = int.Parse(Marq),
                            Intitule = Property.GetValue(List.ToList()[0], null).ToString(),
                        });
                    }
                }
            }
            return(Return);
        }
Exemple #25
0
        public List <PsCartRule> List()
        {
            System.Linq.IQueryable <PsCartRule> Return = from Table in this.DBPrestashop.PsCartRule
                                                         select Table;

            return(Return.ToList());
        }
Exemple #26
0
        public List <PsManufacturerLang> List()
        {
            System.Linq.IQueryable <PsManufacturerLang> Return = from Table in this.DBPrestashop.PsManufacturerLang
                                                                 select Table;

            return(Return.ToList());
        }
        public List <PsOrderInvoicePayment> List()
        {
            System.Linq.IQueryable <PsOrderInvoicePayment> Return = from Table in this.DBPrestashop.PsOrderInvoicePayment
                                                                    select Table;

            return(Return.ToList());
        }
        public async static Task <PagedList <T> > ToPagedList(System.Linq.IQueryable <T> source, int pageNumber, int pageSize)
        {
            var count = source.Count();
            var items = await Task.FromResult(source.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList());

            return(new PagedList <T>(items, count, pageNumber, pageSize));
        }
        public List <Address> List()
        {
            System.Linq.IQueryable <Address> Return = from Table in this.DBLocal.Address
                                                      select Table;

            return(Return.ToList());
        }
Exemple #30
0
        public static IQueryable <TSource> AddOrderAndPageFilters <TSource>(this System.Linq.IQueryable <TSource> input, FilterModelBase filter)
        {
            if (filter != null)
            {
                if (filter.OrderBy.Length > 0)
                {
                    input = input.OrderBy(filter.OrderBy);
                }
                else if (filter.OrderByDescending.Length > 0)
                {
                    input = input.OrderBy(filter.OrderByDescending + " DESC");
                }

                if (filter.Skip > 0 && filter.Take > 0)
                {
                    return(input
                           .SkipIf(true, filter.Skip)
                           .TakeIf(true, filter.Take));
                }
                return(input
                       .SkipIf(filter.Page > 0, filter.Page * filter.PageLimit)
                       .TakeIf(filter.PageLimit > 0, filter.PageLimit));
            }
            return(input);
        }