EF中使用SQL语句增删改查
string sqlTaskLimit = $@"UPDATE TaskLimit SET Total = Total + {visit.DeepDose} WHERE TaskID = \'{visit.TaskID}\' AND( ((PeriodType IN(SELECT PeriodType FROM dbo.Period WHERE PeriodStyle = \'R\')) AND \'{visit.EndDT}\' >= PeriodStart) OR ((PeriodType IN(SELECT PeriodType FROM dbo.Period WHERE PeriodStyle != \'R\')) AND \'{visit.EndDT}\' >= PeriodStart AND \'{visit.EndDT}\' < PeriodExpiry) ) AND Enabled = \'Y\' AND ReadingType = 1";
_db.Database.ExecuteSqlCommand(sqlTaskLimit);
_db.SaveChanges();
//注:_db是创建的EF上下文对象,ExecuteSQLCommand(string query,params Parameter[] pms);
版权声明:本文为powerworld原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。