1 回答

TA貢獻1779條經驗 獲得超6個贊
我改用字典,但仍然不確定是否有更快的方法從集合中檢索值:
var Lookup = Lines.Entities.Where(e => e.GetAttributeValue<OptionSetValue>("new_time").Value == 100000001).Select(r => new
{
group = r.GetAttributeValue<OptionSetValue>("new_group").Value,
desc = r.GetAttributeValue<string>("new_desc"),
numbers = new Dictionary<string, int>()
{
{"monday", r.GetAttributeValue<int>("new_mondayunits") },
{"tuesday", r.GetAttributeValue<int>("new_tuesdayunits") },
{"wednesday", r.GetAttributeValue<int>("new_wednesdayunits") },
{"thursday", r.GetAttributeValue<int>("new_thursdayunits") },
{"friday", r.GetAttributeValue<int>("new_fridayunits") }
}
}).ToDictionary(t => t.group.ToString() + t.desc, t => t.numbers);
var quan = Lookup.ContainsKey(key) ? amLookup[key][currentday] : 0;
- 1 回答
- 0 關注
- 102 瀏覽
添加回答
舉報