0
我想加入2-3列表中有來自數據庫的數據和2列表有數據作爲對象類型如何從中得到實際結果? 這裏是我的代碼和對象列表無法創建「匿名類型」類型的常量值。只有原始類型或枚舉類型在此上下文中受支持。在Linq C#
var calls = context.queued_calls;
//to get classifications into list
var classificationsToList = (from c in context.classifications
select new { c.classification_id, c.classification1 }).ToList();
//to get tha users from the user table
var users = (from u in context.users
select new { u.user_id, u.first_name, u.last_name }).ToList();
//to get agents from agents table
var agents = (from a in context.agents
select new { a.agent_id, a.user_id }).ToList();
這是四個列表中的對象,在這裏是我執行到它
var agentsClass = (from cs in calls
join ag in agents on cs.agent_id equals ag.agent_id
join u in users on ag.user_id equals u.user_id
join cls in classificationsToList on cs.classification_id equals cls.classification_id
group cs by new { cs.classification_id, cls.classification1, cs.agent_id, u.user_id } into clas
select new { agent_id = clas.Key.agent_id, user_id = clas.Key.user_id, classification = clas.Key.classification1, classifications_count = clas.Count() }).OrderBy(a => a.agent_id).ToList();
您無法使用內存列表(所有其他列表)連接數據庫查詢('context.queued_calls')。 – Evk
我得到了它正在工作的解決方案只需要將var calls = context.queued_calls.ToList() –