一、C#.net方法函数
1.1、对象引用对于非静态的字段方法或属性
解决方案一(推荐):实例化
解决方案二:static静态方法
解析:static都是在类初始化的时候加载的,而非静态的变量都是在对象初始化的时候加载
1.2、引用型赋值,两个list值一起改变
解决方案一:序列化-反序列化:
var modeldtlList = context._SFC_TECHNICS_STANDARD_DTL.Where(V => V.ORG_ID == orgId && V.ENTERPRISE_ID == enterpriseId && V.TECHNICS_ID == ID).ToList(); List<SFC_TECHNICS_STANDARD_DTL> list = JsonConvert.DeserializeObject<List<SFC_TECHNICS_STANDARD_DTL>>(JsonConvert.SerializeObject(modeldtlList)) ;
1.3Datatable转list
解决方案一:序列化-反序列化:
dynamic sche_no = cmdissueno .Where(cmdissueno.ColEquipmentCode == equipmentcode, cmdissueno.ColEnterpriseId == enterpriseId, cmdissueno.ColOrgId == orgId).OrderbyAsc(cmdissueno.ColProductNo) .Select(cmdstation.ColStationName);
List<ScheProdNoModel> sche_nolist = JsonConvert.DeserializeObject<List<ScheProdNoModel>>(JsonConvert.SerializeObject(sche_no))
解决方案二:反射
DataTable和List互转https://www.cnblogs.com/junhuang/p/6472787.html
来源:oschina
链接:https://my.oschina.net/u/4268394/blog/3788598