/// <summary>
    /// 按条件删除多个实体
    /// </summary>
    /// <param name="where"></param>
    /// <returns></returns>
    public virtual int BatchDelete(Expression <Func <T, bool> > where)
    {
        var list = context.Set <T>().Where(where).AsNoTracking().ToList();

        foreach (var item in list)
        {
            context.Entry(item).State = EntityState.Deleted;
        }
        return(context.SaveChanges());
    }
        public static string GetLZCode()
        {
            lock (_lock)
            {
                var dt    = DateTime.Now.Date;
                var data  = context.Set <LZCodeGenerate>().Where(m => m.CurrentDate >= dt).FirstOrDefault();
                var _code = "A";
                if (data != null)
                {
                    if (data.LZCode.Length > 7)
                    {
                        var _tempCode = data.LZCode.Substring(9, 1).ToUpper();
                        if (array.Contains(_tempCode))
                        {
                            var index = array.ToList().IndexOf(_tempCode);
                            _code = array[index + 1];
                        }
                    }
                    data.LZCode = $"{dt.ToString("yyyyMMdd")}_{_code}_KGB";
                    context.Entry(data).State = EntityState.Modified;
                    context.SaveChanges();
                }
                else
                {
                    LZCodeGenerate entity = new LZCodeGenerate()
                    {
                        LZCode      = $"{dt.ToString("yyyyMMdd")}_{_code}_KGB",
                        CurrentDate = dt
                    };
                    context.Entry(entity).State = EntityState.Added;
                    context.SaveChanges();
                }

                return($"{dt.ToString("yyyyMMdd")}_{_code}_KGB");
            }
        }
        public List <CompanySummary> GetTopList(int top, Expression <Func <CompanySummary, bool> > where)
        {
            ZHCC_GAPlanEntities context = new ZHCC_GAPlanEntities();

            return(context.Set <CompanySummary>().Where(where).OrderByDescending(m => m.ID).AsNoTracking().Take(top).ToList());
        }
Esempio n. 4
0
        public Model.EF.vFlightPlan GetvFlightPlan(Guid id)
        {
            var context = new ZHCC_GAPlanEntities();

            return(context.Set <vFlightPlan>().Where(u => u.FlightPlanID == id).FirstOrDefault());
        }
        public List <News> GetTopList(int top, Expression <Func <News, bool> > where)
        {
            ZHCC_GAPlanEntities context = new ZHCC_GAPlanEntities();

            return(context.Set <News>().Where(where).OrderByDescending(m => m.IsTop).ThenByDescending(m => m.CreateTime).AsNoTracking().Take(top).ToList());
        }