I have a entity say Computers with properties Dnshostname and navigation property TechnicalProductsHosted. Computers to TechnicalProductsHosted is a many to one and one to many relationship. TechnicalProductsHosted is TechnicalProducts in the odata. Entity TechnicalProducts has a navigation property ResponsibleUser with a many to one relationship. ResponsibleUser is Employee in odata. Employee has a navigation property Manager with a many to one realtionship. When i click on Manager it takes me to Employee entity.I wish to get the list of manager names. I am using Linqpad. Below is the code.
void Main()
{
var a = from cpuid in Computers
where cpuid.DnsHostName == "xyz"
select new {
ITManager = cpuid.TechnicalProductsHosted.Select (x => x.ResponsibleUser.Manager.Select(z => new { ITManager = z.Name })),
};
Console.WriteLine(a);
}
This is the error.
‘LINQPad.User.Employee’ does not contain a definition for ‘Select’ and no extension method ‘Select’ accepting a first argument of type ‘LINQPad.User.Employee’ could be found (press F4 to add a using directive or assembly reference)
I assume that Manager property is a singleton (it’s not a collection). In that case you can use Select on it.
Instead use something like this:
This will give you a list of computers with the specified host name and on each one a list of managers who’s report is responsible for the products. Note that there are likely to be duplicates though.
If you could describe what the query should achieve there might be better options.