How to do a join with Lync and Entity Framework v4.0
Posted on 2015-02-08
I have a sql server database from which I have created an edmx file in my csharp project. The database has all the requisite foreign keys setup and I can see these as NavigationProperties in the XML view of the edmx. All tables have come through as entities correctly.
In SQL I can run a query as follows:
SELECT * FROM Card.CardRequest cr
JOIN product.CompanyProductDesign cpd ON cpd.CompanyProductDesignID = cr.CompanyProductDesignID
JOIN product.ProductDesignCOntent pdc ON cpd.CompanyProductDesignID = pdc.CompanyProductDesignID
which will return only the rows that have been matched from all tables (in my case 6 rows). However I am struggling to get the same result using EF and Lync.
I have got the following code in my c# program:
using (PrepayEntities ent = new PrepayEntities())
cardRequests = ent.CardRequest
cr.CRIFileCreated == true
cr.CreationEmailSent == false
which I know includes an extra Where condition but in any case returns all the rows (in my case 6100 rows). I have tried every possibility from examples that I have found the Internet but just can't seem to crack it - I either get 6100 rows or none.
Please can someone point me in the right direction for what I am sure is a simple solution