Consider:
class Foo
{
public string Name{get;set;}
public string[] WebSites{get;set;}
}
I have a query:
var allFoo=db.Persons.Select(p=>new Foo()
{
Name=p.Name,
WebSites=p.WebSites.Select(q=>q.Caption).ToArray(),
}).ToList();
But i get error ” LINQ to Entities does not recognize the method ‘System.String[] ToArray… “.
How to i get All foo and websites string in a array with linq to entities?
Something like this should work:
This creates a collection of anonymously-typed objects to hold the results of the query. You can then iterate over those objects to create your collection of
Foo.