public static void Add(List <string> ids, List <string> codes) { using (pm2Entities entities = new pm2Entities()) { if ((ids != null) && (codes != null)) { PrjMember member = new PrjMember(); foreach (string str in ids) { Guid guid = new Guid(str); List <string> list = (from m in entities.PT_PrjMember where m.PrjGuid == guid select m.PT_yhmc.v_yhdm).ToList <string>(); foreach (string str2 in codes) { if (!list.Contains(str2)) { member.AddSign(guid, str2, entities); } } } entities.SaveChanges(); } } }
public static void Add(string id, List <string> codes) { using (pm2Entities entities = new pm2Entities()) { Guid guid = new Guid(id); PrjMember member = new PrjMember(); List <string> list = GetCodes(id); using (List <string> .Enumerator enumerator = list.GetEnumerator()) { string code; while (enumerator.MoveNext()) { code = enumerator.Current; if (!codes.Contains(code)) { PT_PrjMember entity = (from m in entities.PT_PrjMember where (m.PrjGuid == guid) && (m.PT_yhmc.v_yhdm == code) select m).FirstOrDefault <PT_PrjMember>(); if (entity != null) { entities.DeleteObject(entity); DelFile(entity.PrjMemberId); } } } } foreach (string str in codes) { if (!list.Contains(str)) { member.AddSign(guid, str, entities); } } entities.SaveChanges(); } }