Click here to Skip to main content
15,904,638 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
var data = (from m in ContextDb.Modules
           join itm in ContextDb.RoleAssignments on m.ModuleId equals itm.ModuleId && itm.RoleId = 2
           select new RoleAssignmentModel { RoleAssignmentId = itm.RoleAssignmentId, RoleId = itm.RoleId}).ToList();


i am having 3 tables of name tbl_Role, Modules and RoleAssignment. when i use the above query , got an error as -operator '&&' cannot be applied to operands of type "int?" and "int"
in ( itm.ModuleId && itm.RoleId = 2...).
Posted
Updated 31-Oct-13 1:24am
v3
Comments
Thomas ktg 31-Oct-13 7:11am    
Try it with AND instead of &&.
prthghosh999 31-Oct-13 7:32am    
Its a Linq Query. so i cant use AND instead of &&

1 solution

Try:
C#
var data = (from m in ContextDb.Modules
           join itm in ContextDb.RoleAssignments on (m.ModuleId == itm.ModuleId) && (itm.RoleId == 2)
           select new RoleAssignmentModel { RoleAssignmentId = itm.RoleAssignmentId, RoleId = itm.RoleId}).ToList();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900