public Dictionary <int, List <Mst_item_shop> > GetMstCabinet() { IEnumerable <XElement> enumerable = Utils.Xml_Result(Mst_item_shop.tableName, Mst_item_shop.tableName, null); if (enumerable == null) { return(null); } var enumerable2 = Enumerable.Distinct(Enumerable.Select(Extensions.Elements <XElement>(enumerable, "Cabinet_no"), (XElement key) => new { no = int.Parse(key.get_Value()) })); Dictionary <int, List <Mst_item_shop> > dictionary = Enumerable.ToDictionary(enumerable2, key => key.no, val => new List <Mst_item_shop>()); using (IEnumerator <XElement> enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) { XElement current = enumerator.get_Current(); Mst_item_shop mst_item_shop = null; Model_Base.SetMaster <Mst_item_shop>(out mst_item_shop, current); dictionary.get_Item((int)mst_item_shop.Cabinet_no).Add(mst_item_shop); } } if (!Enumerable.Any <Mem_ship>(Comm_UserDatas.Instance.User_ship.get_Values(), (Mem_ship x) => x.Stype == 22)) { Mst_item_shop mst_item_shop2 = Enumerable.FirstOrDefault <Mst_item_shop>(dictionary.get_Item(1), (Mst_item_shop x) => x.Item1_id == 23); dictionary.get_Item(1).Remove(mst_item_shop2); } return(dictionary); }
public Dictionary <int, List <Mst_item_shop> > GetMstCabinet() { IEnumerable <XElement> enumerable = Utils.Xml_Result(Mst_item_shop.tableName, Mst_item_shop.tableName, null); if (enumerable == null) { return(null); } var source = (from key in enumerable.Elements("Cabinet_no") select new { no = int.Parse(key.Value) }).Distinct(); Dictionary <int, List <Mst_item_shop> > dictionary = source.ToDictionary(key => key.no, val => new List <Mst_item_shop>()); foreach (XElement item2 in enumerable) { Mst_item_shop instance = null; Model_Base.SetMaster(out instance, item2); dictionary[instance.Cabinet_no].Add(instance); } if (!Comm_UserDatas.Instance.User_ship.Values.Any((Mem_ship x) => x.Stype == 22)) { Mst_item_shop item = dictionary[1].FirstOrDefault((Mst_item_shop x) => x.Item1_id == 23); dictionary[1].Remove(item); } return(dictionary); }