![](/img/trans.png)
[英]C# - Linq : Unable to create a constant value of type Only primitive types or enumeration types are supported in this context.
[英]Unable to create a constant value of type 'Anonymous type'. Only primitive types or enumeration types are supported in this context. in Linq C#
我想加入2-3個具有數據庫數據的列表和2個具有數據作為對象類型的列表的方法,如何從中獲取實際結果? 這是我的代碼和對象列表
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();
我得到了解決方案,只是我需要將調用轉換為List並解決了錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.