Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you are over thinking the LINQ a little, try the following LINQ. The only thing I am not 100% sure about is the GIGCOUNT results so that might take a bit of fiddling with.</p> <pre><code>( from A in SMARTISTDETAILS join PC in SMPRSCLAIMS on A.ARTISTID equals PC.FKARTISTID join categories in SMCATEGORIES on PC.FK_CATEGORYID equals categories.ID join categoryType in SMCATEGORIESTYPE on categories.FK_CATEGORYTYPEID equals categoryType.ID join link in SMPRSLIVECLAIMLINK on PC.PRSCLAIMID equals link.FKPRSCLAIMID join liveClaims in SMLIVECLAIMS on link.FKLIVECLAIMID equals liveClaims.LIVECLAIMSID join bulkDetail in BULKCLAIMDETAIL on PC.PRSCLAIMID equals bulkDetail.FKPRSCLAIMID into BULK_DETAILS from BCD in BULK_DETAILS.DefaultIfEmpty() join bulkClaim in BULKCLAIM on BCD.ID_BULKCLAIM equals bulkClaim.ID_BULKCLAIM into BULK_CLAIMS from BC in BULK_CLAIMS.DefaultIfEmpty() where ( PC.EXPORTTYPE &gt; 0 ) &amp;&amp; ( A.DBID == 1 ) &amp;&amp; ( PC.EXPORTTYPE == 1 &amp;&amp; liveClaims.GIGDATE &lt; DateTime.Now.AddYears(-1) ? 0 : 1 ) == 1 orderby PC.DATEOFCLAIM descending select new { PC.PRSCLAIMID, DateofClaim = PC.DATEOFCLAIM, PC.PRSREFNO, PC.FKARTISTID, PC.FKLISTINFOID, PC.STATUS, PC.FROMDNN, PC.EXPORTTYPE, PC.FK_CATEGORYID, A.LOGINNAME, A.BANDNAME, categoryType.CATEGORYTYPE, // This gets me the correct count now GIGCOUNT = SMPRSLIVECLAIMLINK.Where(LINK =&gt; LINK.FKPRSCLAIMID == PC.PRSCLAIMID &amp;&amp; (PC.EXPORTTYPE == 1 &amp;&amp; LINK.FKLIVECLAIMIDSMLIVECLAIMS.GIGDATE &lt; DateTime.Now.AddYears(-1) ? 0 : 1) == 1).Count(), PROCESSEDID = categories.ID, categories.CATEGORY, BULKCLAIM_NAME = BC.FILENAME ?? String.Empty }) // Use distinct to get rid of duplicate rows .Distinct() .ToList() .GroupBy(o =&gt; o.PRSCLAIMID ) </code></pre> <p>EDIT:</p> <p>I changed how I calculate the GIGCOUNT property, this should now return the correct number. You will also want to use the Distinct() extension so that duplicate rows are removed.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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