Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.

代码如下:

  

var query = from s in db.LoginUserServices
							join ss in db.Services on s.ServiceType equals ss.Code into s_ss_join
							from s_ss in s_ss_join.DefaultIfEmpty()
							where s.LoginUserID.Equals(LoginUserID) 
							select new
							{
								// ServiceType = s.ServiceType,
								ServiceName = s_ss.Name,
								ServiceProperty = s_ss.Property,
								ServiceCode = s.ServiceType
							};

 Linq to Array中报错:

报错位置:

Equals

改为:

var query = from s in db.LoginUserServices
							join ss in db.Services on s.ServiceType equals ss.Code into s_ss_join
							from s_ss in s_ss_join.DefaultIfEmpty()
							where s.LoginUserID==LoginUserID 
							select new
							{
								// ServiceType = s.ServiceType,
								ServiceName = s_ss.Name,
								ServiceProperty = s_ss.Property,
								ServiceCode = s.ServiceType
							};

 

 

  

posted @ 2017-04-20 11:32  幸福安康  阅读(1127)  评论(0编辑  收藏  举报