In that in business logic layer, I have created a class like this:
public List SelectAllData()
{
try
{
return (from obj i
If you return RoleHasRight you need to construct it, not an anonymous type as you do now:
select new RoleHasRight
{
obj,
role.roleName
}).ToList();
You are creating a new, anonymous Type by using:
select new { obj,role.roleName}
This type has 2 properties (the rolename and the roleHasRights object). In order to be able to return the same inforamtion by the method, you need to create a class with this information, or to return a dynamic.
e.g.
public class RoleHasRightInfo {
public string Rolename {get;set;}
public roleHasRight Right {get;set;}
}
and create it within the linq expression like this:
select new RoleHasRightInfo(){ Right=obj,Rolename = role.roleName}
The method would then need to return a List of this new type:
public List<RoleHasRightInfo> SelectAllData() {
...
}