【1】linq表达式
T_DATA_PE tp =new T_DATA_PE();
int unit=int.Parse(context.Request.Form["Unit"]);
int Style=int.Parse(context.Request.Form["style"]);
int Community=int.Parse(context.Request.Form["community"]);
DateTime Monitortime= Convert.ToDateTime(context.Request.Form["monitortime"]);
var data = ef.FindAll<T_DATA_PE>(x => x.Unit == unit && x.style == Style && x.community == Community && x.monitortime == Monitortime).FirstOrDefault();
tp = data;
/*tp.Unit = data.Unit;
tp.community = data.community;
tp.style = data.style;
tp.monitortime = data.monitortime;
tp.image1 = data.image1;
tp.image2 = data.image2;
tp.image3 = data.image3;*/
【2】linq---update报错
https://www.cnblogs.com/godbell/p/7360739.html
附加类型“AirQuality.Model.T_DATA_PE的实体失败,因为相同类型的其他实体已具有相同的主键值。在使用 "Attach" 方法或者将实体的状态设置为 "Unchanged" 或 "Modified" 时如果图形中的任何实体具有冲突键值,则可能会发生上述行为。这可能是因为某些实体是新的并且尚未接收数据库生成的键值。在此情况下,使用 "Add" 方法或者 "Added" 实体状态跟踪该图形,然后将非新实体的状态相应设置为 "Unchanged" 或 "Modified"。
bool addresult = ef.Update<T_DATA_PE>(tp);更新数据
https://blog.youkuaiyun.com/huqitu/article/details/3765069?utm_source=blogxgwz7
https://blog.youkuaiyun.com/txhdjackie/article/details/77531745
/bool addresult = ef.Update<T_DATA_PE>(tp);//直接更新会报错
ef.Delete<