私は4つのテーブルを持っています。Transactions
、Attachment
、SubReportType
& SubRepRole
です。私はキャッシュ上でユーザーの役割を持っています。私は今、このエラーを取得LINQクエリがどこにあるか
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();
[ユーザーが複数の役割を有することができる]ユーザーの役割に関連しているそれらの添付ファイルを持つようにしたい:
Unable to create a constant value of type 'User.Common.DataContract.UserRole'. Only primitive types or enumeration types are supported in this context.
これを助けてください。 "含める"も試しましたが、型キャスティングエラーが発生しています。ロールがuser_details.UserRoleModuleWiseにあるレコードを持っていただけです。 user_details.UserRoleModuleWiseは、あなたが正しい値の配列でContains
を使用する必要がRoleIdとロール名
あなたは/ *どこでobj.Contains(subreprl.RoleId)*でチェックしたいですか? –