I have the following view-model class inside my MVC application:-
public class CustomerDetails
{ public AccountDefinition AccountDefinition {get; set;}
public SDOrganization SDOrganization {get; set;}
public IEnumerable<SiteDefinition> SiteDefinition { get; set; }
public IEnumerable<AaaPostalAddress> AaaPostalAddress { get; set; }
public IEnumerable<AaaContactInfo> AaaContactInfo { get; set; }
public IEnumerable<SDUser> SDUser { get; set; } }
Btu if i try to write this query :-
var customerDetails = entities.AccountDefinitions
.Where(a => a.ORG_ID == id)
.Select(cd => new CustomerDetails
{
AccountDefinition = cd,
SDOrganization = cd.SDOrganization,
AaaPostalAddress = cd.SDOrganization.AaaPostalAddresses,
AaaContactInfo = cd.SDOrganization.AaaContactInfoes,
SiteDefinition = cd.SiteDefinitions,
SDUser = cd.SiteDefinitions.Select(p => p.UserSiteMappings.Select(p2 => p2.SDUser))//this is raising the error
})
.SingleOrDefault();
return customerDetails;
}
I will get the following error:-
Cannot implicitly convert type
System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<TMS.Models.SDUser>>
toSystem.Collections.Generic.IEnumerable<TMS.Models.SDUser>
. An explicit conversion exists (are you missing a cast?)
So what is wrong with my code??