Class1 contains the RetrieveAll method that I'm trying to call from Class2. I just can't get this thing happy as it's not like the types I put in for my Generic list I guess. I've glossed over
the implementation of Class1 and it's returning an IEnumerable I guess:
Class1(hhDbRoleProvider):
namespace xxx.hh.Business.Entities
{
public class hhDbRoleProvider : IRoleProvider
{
public IRole New(string roleName)
{
return new Role(this)
{
RoleName = roleName,
Description = string.Empty
};
}
public IEnumerable RetrieveAllRoles()
{
List<IRole> roles = new List<IRole>();
using (IDataReaderEnumerable dalRoles = Role.RetrieveAll())
foreach (Role dalRole in dalRoles)
roles.Add(new Role(dalRole));
return roles;
}
}
}
Class2 (HHRoleProvider)
namespace xxx.hh.Common.Roles
{
classHHRoleProvider : RoleProviderBase
{
public override Configuration.Roles.Role[] GetRoles()
{
// Grab all the roles from the DB
hhDbRoleProvider roleProvider;
The error is on the last line and I cannot figure out how the hell to get it to be "happy":
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<xxx.BusinessInterfaces.Security.IRole>' to 'System.Collections.Generic.List<xxx.BusinessInterfaces.Security.IRole>'. An explicit conversion exists (are you missing a cast?)
dba123
Contributor
2726 Points
1364 Posts
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<xxx>' to 'System.Collectio...
May 23, 2008 07:53 PM|LINK
Class1 (hhDbRoleProvider):
namespace xxx.hh.Business.Entities { public class hhDbRoleProvider : IRoleProvider { public IRole New(string roleName) { return new Role(this) { RoleName = roleName, Description = string.Empty }; } public IEnumerable RetrieveAllRoles() {List<IRole> roles = new List<IRole>();
using (IDataReaderEnumerable dalRoles = Role.RetrieveAll()) foreach (Role dalRole in dalRoles) roles.Add(new Role(dalRole)); return roles; } } }Class2 (HHRoleProvider)
The error is on the last line and I cannot figure out how the hell to get it to be "happy":
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<xxx.BusinessInterfaces.Security.IRole>' to 'System.Collections.Generic.List<xxx.BusinessInterfaces.Security.IRole>'. An explicit conversion exists (are you missing a cast?)