This is the query I am running in DB:
select UM.USER_NAME, RM.ROLE_ID, RM.ROLE_NAME
FROM [MICommonDB].[dbo].[ROLE_USER_MAPPING] as RUM
join [MICommonDB].[dbo].[ROLE_MASTER] as RM ON RM.ROLE_ID=RUM.ROLE_ID
join [MICommonDB].[dbo].[USER_MASTER] UM ON UM.USER_ID = RUM.USER_ID
where UM.USER_NAME='useruser'
which is giving me proper result(i.e., 2 records) when running in SQL server.
Now I have created below method in a class with same query (I am calling this method inside Controller):
public IEnumerable<RoleUserDO> getRoleNameByUserName(string userName)
{
IEnumerable<RoleUserDO> strResult = null;
strResult = (from RUM in oDBContext.ROLE_USER_MAPPING
join RM in oDBContext.ROLE_MASTER on RUM.ROLE_ID equals RM.ROLE_ID
join UM in oDBContext.USER_MASTER on RUM.USER_ID equals UM.USER_ID
where UM.USER_NAME.Equals(userName)
select new RoleUserDO
{
//USER_NAME = UM.USER_NAME,
//ROLE_ID = RM.ROLE_ID,
ROLE_NAME = RM.ROLE_NAME
}).ToList();
return strResult.AsQueryable();
}
but it returns only 1 record instead of 2 records(when compared with DB query)
Please tell what is wrong in my method and why the return records are not matching with DB query records ?
Please note that I am new in C# asp.net MVC.