Assume I'm working with the graph database from this sample (SQL Server 2017):
https://learn.microsoft.com/en-us/sql/relational-databases/graphs/sql-graph-sample
I have the following SQL query:
-- Find Restaurants that John likes
SELECT Restaurant.name
FROM Person, likes, Restaurant
WHERE MATCH (Person-(likes)->Restaurant)
AND Person.name = 'John';
I created a Model in C# using EF 6.1.3 and it autogenerates all the classes and everything from the database (EF Designer from database). This all works fine. I can even query all the people by using a simple method like:
public ICollection<People> ListPeople() => Entities.Peoples.ToList();
Now, if we come back to the original query, where I would like to find restaurants that John likes... how will I do this in Entity Framework? do I need to use a LINQ query or can I just call the entities? (presumably I can't because there doesn't seem to be any physical relationship between the tables, only by finding them in the edges)
I was thinking of something like
public ICollection<Restaurant> ListRestaurantsLikedByPerson(string personName)
{
var result = from restaurant in Entities.Restaurants, person in Entities.Peoples, likes in Entities.likess
where match (person - likes -> restaurant)
and person.name = personName;
return result;
}
But this syntax is incorrect... how can I do this query?