I have 3 tables in my database
- Country
- City
- House
Country table looks like
CountryID
Name
City table looks like
CountryID
CityID
Name
House
CountryID
CityID
HouseID
Name
I use LINQ to SQL and the above tables become classes and have their properties etc.
Now I have my own abstract class called
Location
And created Partial Classes for Country, City, House that inherit the Location abstract class
and hence can have common functionality like FindByID() and properties like .Parent (of type Location)
Now lets take .Parent which basically returns the Parent for each class
so
House will return
.Parent //as City
City will return
.Parent //as Country
Country will return
.Parent //as Country
Now when trying to use
City.Parent in a LINQ to SQL statement I get a
The member 'Location`1[City].Parent' has no supported translation to SQL.
Now people have been mentioning about how you can use Lamda expressions to resolve this. Can someone give me a good example for this kind of situation
what should .Parent look like
Location Parent
{
get
{
//Please fill Lamda expression here
}
}