I'm trying to create a Typed List based on two related entities Frukt and Kategori (swedish for Fruit and Category, sorry for that)
The entities are based on the following tables in my testdb:
Frukt
fruktId (PK)
Namn
kategoriId (FK)
Kategori
kategoriId (PK)
Namn
I have designed the typed list to include fruktId and Namn from entity Frukt and Namn (with alias Kategori) from entity Kategori.
When using the generated code to fetch rows from the typed list I got teh following error:
System.Data.SqlClient.SqlException: The multi-part identifier "llbltest.dbo.Kategori.namn" could not be bound..
Tracing the SQL generated by the llblgen-code I see the problem. The inner join to table Kategori is missing:
SELECT [llbltest].[dbo].[Frukt].[fruktId] AS [FruktId], [llbltest].[dbo].[Frukt].[namn] AS [Namn], [llbltest].[dbo].[Kategori].[namn] AS [Kategori] FROM [llbltest].[dbo].[Frukt]
It should be something like this to work:
SELECT [llbltest].[dbo].[Frukt].[fruktId] AS [FruktId], [llbltest].[dbo].[Frukt].[namn] AS [Namn], [llbltest].[dbo].[Kategori].[namn] AS [Kategori]
FROM [llbltest].[dbo].[Frukt]
INNER JOIN [llbltest].[dbo].[Kategori] ON [llbltest].[dbo].[Frukt].[kategoriId] =[llbltest].[dbo].[Kategori].[kategoriId]
So, what am I doing wrong here? Why isn't the correct sql generated?
Regards.