Based on the code you have shown, City nor USStates are queryable with both needing to be a collection/List<T> List<City> and a List<USStates>, becuase List<T> implements IEnumerable and that makes a List<T> queriable by Linq. I could be wrong, but for
sure City is not queryable it looks to me.
public City City { get; set; }
public USStates USStates { get; set; }
var StateAndCity = (from c in City
join st in USState
on c.Id equals st.Id
orderby c.Description
select new { c.Description, st.State }).ToList();
return Page();
I have attempted to implement this solution, however, I am getting an error "CS1936 Could not find an implementation of the query pattern for source type City. 'Join' not found."
public Cities List <City> { get; set; } = new List<City>();
public States List<USStates> { get; set; } - new List<USStates>();
Now somehow you are going to need to load each collection with the appropriate object, and then you can use Linq to query them.
If you find the post has answered your issue, then please mark post as 'answered'.
Contributor
4973 Points
4264 Posts
Re: .Net Core Best Practices For Returning Data From Linked (Foreign Key) Table
Dec 16, 2019 10:08 AM|DA924|LINK
Based on the code you have shown, City nor USStates are queryable with both needing to be a collection/List<T> List<City> and a List<USStates>, becuase List<T> implements IEnumerable and that makes a List<T> queriable by Linq. I could be wrong, but for sure City is not queryable it looks to me.
https://www.tutorialsteacher.com/csharp/csharp-list
public Cities List <City> { get; set; } = new List<City>();
public States List<USStates> { get; set; } - new List<USStates>();
Now somehow you are going to need to load each collection with the appropriate object, and then you can use Linq to query them.