I am trying to turn this sql statement into a fluent nhibernate mapping :
select *
from Project p
inner join ProjectData pd on p.Project = pd.Project
inner join ProjectCompany pc on p.Project = pc.Project and pc.InitComp = 'Yes' and pc.Company = pd.LogComp
inner join ProjectCustomer cust on cust.id = pd.custid
I'm facing a number of problems for getting this statement into a single entity(all joins are a 1 on 1 relationship).
I am aware that a single view would solve my issues but alas i don't have the privileges to create one.
Currently my code looks like this
Table("Project");
Id(p=> p.Number);
Join("ProjectData", j =>
{
j.Fetch.Join();
j.KeyColumn("Project");
j.Map(pd => pd.Customer);
});
Map(p => p.Complexity);
The problems i am facing are :
A lot of questions for something so trivial in sql but i can't seem to find a simple answer on the internet other then create a view.
I ended up with a raw sql query and using a datareader to manually fill my object.
This worked cause i only needed to read from a table and not write.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.