I'm using LLBLGn 3.1 to generate EF v.4 model and I came across an issue when using Typed List from an inherited entity.
I'll use **AdventureWorks **database as an example:
- I've made Sales.SalesPerson a HumerResources.Employee.
- I've created the typed list called **SalesPersonShort **with fields: EmployeeId,Title and SalesYTD. LLBLGen validates the model fine.
- Now I oped the generated code in VS and try to build the project it giev an error:
AW.AdventureWorksEFDataContext' does not contain a definition for 'SalesPeople' and no extension method 'SalesPeople' accepting a first argument of type 'AW.AdventureWorksEFDataContext' could be found.
I've looked at the code of the Get... method and it's got the following
public IQueryable<SalesPersonShortTypedListRow> GetSalesPersonShortTypedList()
{
var current0 = this.SalesPeople;
return current0.Select(v=>new SalesPersonShortTypedListRow() { Title = v.Title, EmployeeId = v.EmployeeId, SalesYtd = v.SalesYtd } );
}
So why LLBLGen generates a code referencing **SalesPeople **when there's no such property??
How do I make LLBLGen generate the correct code?
The correct code in this case would be
var current0 = this.Employees.OfType<SalesPerson>();
Of cource I can correct it manually but it's real PIA to do it every time after I generate the code.