I'm trying to perform a linq to entities query on a table that's inherited using Table per Type.
The problem I'm having is that I can't get at the properties on the Inhertied table only the properties on the Base Table.
var qry = from i in _DB.BaseTable
where i is catalogueModel.InheritedTable
// Field Doesn't Exist
// && i.InheritedTableField == "Value"
select i;
When I try to cast the Inherited Table to it's type...
var qry = from i in _DB.BaseTable
where i is catalogueModel.InheritedTable
&& (i as catalogueModel.InheritedTable).InheritedTableField == "Value"
select i;
...the code compiles but i get a cool error which reads
Only text pointers are allowed in work tables, never text, ntext, or image columns. The query processor produced a query plan that required a text, ntext, or image column in a work table.
I suppose my question is How are you supposed to access the properties of the Inherited tables in linq to entities when using Table per Type?
Use .OfType():
var qry = from i in _DB.BaseTable.OfType<InheritedTable>()
select i.InheritedTableField;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With