I would love the solution to my current problem, but I would like EVEN MORE if I can understand what this error actually means.
I have LINQ to SQL classes for two tables in my database: Providers and Destinations . I added the following member to the Provider class:
public IEnumerable<Assignment> Assignments { get { return (new linqDataContext()) .Assignments .Where(a => a.ProviderID == this.ProviderID); } }
Then I bind the GridView using a query that is retrieved from the parent Provider and uses the Destination child, for example:
protected void PopulateProviders() { linqDataContext context = new linqDataContext(); var list = from p in context.Providers where (p.Assignments.Count(a => a.Category == ddlCategory.SelectedValue) > 0) select p; lvProviders.DataSource = list; lvProviders.DataBind(); }
In .DataBind (), when it does run the query, it throws the following error:
Access to the 'System.String Category' member from 'Namespace.Assignment' is not legal by type 'System.Collections.Generic.IEnumerable`1 [Namespace.Assignment].
I tried checking for zeros (a => a! = Null && a.Category ...), but that didn't work. I'm not sure what to try next. I think that if I knew that the error was trying to tell me, I could find a solution. Be that as it may, I do not know why membership would be illegal.
source share