Thought I'd repost this question now I have a better idea of the problem and how to explain it.
My app has been using the .ExecuteQuery<Persons>(qrySQL) approach to pull back data and I want to move away from this and use LINQ to SQL queries.
I have to use 'select new' as I have some fields which need to be excluded completely from the DB call. In Entity Developer 'Persons' is defined as a table (with a [Table] attribute in the code). It's for this reason that when I'm creating a query I can't do the below in my query:
Code: Select all
select new Persons() {
....
}
I did some searches on google and found an article that mentions inheritance. So I gave this a go and made a little progress but not much.
Code: Select all
public class PersonsView : Persons { }
Needless to say I've spent ages trying different tweaks to the LINQ to SQL statement. I decided that I wanted to prove that the table which uses inheritance (PersonsView) could be used by the .ExecuteQuery method:
Code: Select all
myContext.ExecuteQuery<Persons>(qrySQL);
Code: Select all
myContext.ExecuteQuery<PersonsView>(qrySQL);
In short, the problem I'm trying to get over is to be able to select a specific set of fields while holding on to the navigation properties so my child tables will be populated. For the moment I think the problem resides on the fact I'm not using the actual table but one which is using inheritance.
I'd really appreciate some examples that might help sort this out :O)