I am making the journey from an SQL centric world (where I am reasonably fluent) to EF dDbContect with code first and I am struggling. The following is a simplified example; I want to write the following simple SQL query (which took 60 seconds to write):
SELECT
HP.HospitalID
FROM
Hospitals AS HP
JOIN NHSTrusts AS NT
ON NT.NHSTrustID = HP.NHSTrust_NHSTrustID
WHERE
HP.HospitalName + ', ' + NT.NHSTrustName = 'My hospital name including trust'
as an EF style query. I cannot see how to do this and I don't want to drop back into SQL everytime I cannot see how to do something.
Can anyone help:
- On how to frame the above query in EF dbContent
- On a general source of help with
HospitalsandNHSTruststables are related?WHERE HP.HospitalName='hospital name' AND NT.NHSTrustName = 'trust'could potentially be more efficient. Your approach excludes the usage of indexesHP.NHSTrust_NHSTrustID