Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Instead of creating it using the more SQL style Linq syntax (sorry I don't know the proper name for it), you could try taking advantage of the way IQueryable objects work. Basically what you can do is add where clauses where necessary, otherwise omit them. Something along these lines should work:</p> <pre><code>var context = new Entities(); var complaints = from c in context.Complaints join s in context.Statuses on c.Status equals s.Id join service in context.SERVICES on c.ServiceId equals service.Id join u in context.Users on c.CreatedBy equals u.UserId from technician in context.Users.Where(technician =&gt; technician.UserId == c.AssignedTo).DefaultIfEmpty() select new { c.Id, c.Status, s.Name, c.ServiceId, Service = service.Name, c.Title, c.Customer, c.Description, c.CreatedDate, c.CreatedBy, Author = u.Username, c.AssignedBy, c.AssignedTo, Technician = technician.Username, c.AssignedDate }; </code></pre> <p>So keep in mind you haven't actually queried anything yet, because Linq uses deferred execution. Now you can go through and add where clauses</p> <pre><code>if (ASPxComboBoxSupporter.Value != null) { complaints = complaints.Where(c =&gt; c.CreatedBy == (decimal)ASPxComboBoxSupporter.Value); } if (ASPxComboBoxTechnician.Value != null) { complaints = complaints.Where(c =&gt; c.AssignedTo == (decimal)ASPxComboBoxTechnician.Value); } if (ddlService.Value != null) { complaints = complaints.Where(c =&gt; c.ServiceId == (decimal)ddlService.Value); } if (ddlStatus.Value != null) { complaints = complaints.Where(c =&gt; c.Status == (decimal)ddlStatus.Value); } </code></pre> <p>I haven't tested this, so let me know if something isn't working right still.</p>
 

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