【发布时间】:2017-07-13 06:56:01
【问题描述】:
我有 4 张桌子 Transactions、Attachment、SubReportType 和 SubRepRole。我的缓存上有用户角色。我想要那些与用户角色相关的附件[一个用户可能有多个角色]
List<int> userrole = new List<int>();
UserContext user_details = (UserContext)HttpContext.Current.Cache["UserContext"];
IList<UserRole> userrole_id = user_details.UserRoleModuleWise;
var query = (from trans in objContext.Transactions
join attch in objContext.Attachment on trans.TransId equals attch.TransId
join subrept in objContext.SubReportType on trans.SubRepId equals subrept.SubRepId
join subreprl in objContext.SubRepRole on trans.SubRepId equals subreprl.SubRepId
join selectedrole in userrole_id on subreprl.RoleId equals selectedrole.RoleId
/*where obj.Contains(subreprl.RoleId) */orderby trans.TransDate
select new AttachmentModel
{
Createdate = attch.CreatedDateTime,
FileType = attch.FileType,
FileName = attch.FileName,
Attachid = attch.AttachedId,
FileTag = attch.FileTag,
Transid = trans.TransId,
SubReportName = subrept.SubRepName,
RandomPinNo = attch.FileRandomPin
}).ToList();
现在出现这个错误:
无法创建类型的常量值 'User.Common.DataContract.UserRole'。只有原始类型或 在此上下文中支持枚举类型。
请帮忙。也尝试过“包含”,但类型转换错误即将到来。只是想拥有那些角色在 user_details.UserRoleModuleWise 中的记录。 user_details.UserRoleModuleWise 是一个具有 RoleId 和 RoleName 的数组
【问题讨论】:
-
你想检查什么 /*where obj.Contains(subreprl.RoleId) *.