Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can I change a sql query to linq 2 nhibernate?
    primarykey
    data
    text
    <p>I have a query that is driving me crazy,,when I run it in sql it works fine but I dont know how to change it to linq to sql</p> <p>the query is:</p> <pre><code>SELECT organizationstructure.PositionTitle.Title, organizationstructure.Person.FirstName, organizationstructure.Person.LastName, organizationstructure.Department.Name FROM organizationstructure.Department INNER JOIN organizationstructure.Accountability AS Accountability_1 ON organizationstructure.Department.PartyId = Accountability_1.ParentPartyId INNER JOIN organizationstructure.Accountability INNER JOIN organizationstructure.Person ON organizationstructure.Accountability.ChildPartyId = organizationstructure.Person.PartyId INNER JOIN organizationstructure.Position ON organizationstructure.Accountability.ParentPartyId = organizationstructure.Position.PartyId ON Accountability_1.ChildPartyId = organizationstructure.Position.PartyId INNER JOIN organizationstructure.PositionTitle ON organizationstructure.Position.PositionTitleId = organizationstructure.PositionTitle.PositionTitleId </code></pre> <p>and I think this is wrong but I changed it to:</p> <pre><code>query// query is iqueryable of position .Join(Repository&lt;Accountability&gt;.Find(), p =&gt; p.Id, a =&gt; a.Child.Id, (p, a) =&gt; new Tuple&lt;string, string, int?&gt;(((Department)a.Parent).Name, p.PositionTitle.Title, p.Id)) .Join(Repository&lt;Accountability&gt;.Find(), p =&gt; p.Item3, p =&gt; p.Parent.Id, (p, d) =&gt; new Tuple&lt;string, string, int?, string&gt;(p.Item1, p.Item2, p.Item3, d.Child == null ? string.Empty : string.Format("{0}", ((Person)d.Child).FirstName) + " " + ((Person)d.Child).LastName)) </code></pre> <p>whats wrong with it or ow can i change this query??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload