Exemplo n.º 1
0
        public int SavaDailyToSqlServer()
        {
            int m = 0;

            if (dailyList.Count > 0)
            {
                DailyDBContext dailyDBContext = new DailyDBContext();
                dailyList.ForEach(u =>
                {
                    try
                    {
                        Daily dailym = dailyDBContext.DailyModel.FirstOrDefault(mk => mk.DaiReportId == u.DaiReportId);
                        if (dailym != null && dailym.DaiId > 0)
                        {
                            // dailyDBContext.Entry(daily).State = System.Data.Entity.EntityState.Modified;
                        }
                        else
                        {
                            dailyDBContext.DailyModel.Add(u);
                        }
                        m += dailyDBContext.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                });
            }
            return(m);
        }
Exemplo n.º 2
0
 public int AddDailyTest()
 {
     try
     {
         Daily daily = new Daily();
         daily.Remark = "654d54sd";
         DailyDBContext dailyDBContext = new DailyDBContext();
         dailyDBContext.DailyModel.Add(daily);
         int m = dailyDBContext.SaveChanges();
         return(m);
     }
     catch (Exception ex)
     {
         throw;
     }
 }