I'm trying to do a simple join with Simple.Data but I can't get it working. I'm sure that I'm missing something but I don't get it...
SQL:
CREATE TABLE TestA
(
ID INTEGER PRIMARY KEY,
Txt TEXT
);
CREATE TABLE TestB
(
ID INTEGER PRIMARY KEY,
Aref INTEGER,
Txt TEXT,
FOREIGN KEY(Aref) REFERENCES TestA(ID)
);
INSERT INTO TestA
VALUES (1, 'This is Test A!');
INSERT INTO TestB
VALUES (1, 1, 'This is TestB!');
C#:
db.TestB.Find(db.TestB.Aref = db.TestA.ID);
If I run the code I'll get a RuntimeBinderException: 'Simple.Data.ObjectReference' does not contain a definition for 'Aref'.
I'm using Simple.Data.Core/Ado v0.12.2.2 and Simple.Data.Sqlite v0.12.2.4
I already checked the Docs but I can't see my mistake. What I am doing wrong?
Edit: I also tried the index style:
db["TestB"].Find(db["TestB"]["TestA"]["ID"] == db["TestB"]["Aref"]);
The generated SQL looks like this:
select [TestB].* from [TestB] JOIN [TestA] ON ([TestA].[Aref] = [TestB].[ID]) where [TestA].[ID] = [TestB].[Aref]
It seems like that the tables in the ON part are inverted, actually it should be like the WHERE part ...