Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement filtering search for admin
    text
    copied!<p>I have been trying to implement a search page for the admin of my system. Long story short, there a 3 paramaters as criterias. 1. users, 2.projects, 3. customers. The admin can make any combination of those three criterias. for example "I would like to see all users which are assigned to this projects and also all the customers" or "I want to see this customer and this project but all the users" and so on. How do you implement such filtering? I am using asp.net 4.0 and linq just in case.</p> <p>Here is the function content and it is all. I have made it by if conditions but it is not at all healthy.</p> <pre><code>public static List&lt;Data.CurrentActivity&gt; GetUsersActivitySearch(string employeeId, string projectId, string customerId, DateTime startDate, DateTime endDate) { DataClassesDataContext dc = new DataClassesDataContext(General.ConnectionString); if(projectId=="" &amp;&amp; customerId!="") return dc.CurrentActivities.Where(t =&gt; t.User.RecId.ToString() == employeeId &amp;&amp; t.Customer.RecId.ToString() == customerId &amp;&amp; t.ActivityDate &gt;= startDate &amp;&amp; t.ActivityDate &lt;= endDate).ToList(); else if (projectId != "" &amp;&amp; customerId == "") return dc.CurrentActivities.Where(t =&gt; t.User.RecId.ToString() == employeeId &amp;&amp; t.Project.RecId.ToString() == projectId &amp;&amp; t.ActivityDate &gt;= startDate &amp;&amp; t.ActivityDate &lt;= endDate).ToList(); else if (projectId != "" &amp;&amp; customerId != "") return dc.CurrentActivities.Where(t=&gt;t.User.RecId.ToString()==employeeId &amp;&amp; t.Customer.RecId.ToString()==customerId &amp;&amp; t.Project.RecId.ToString()==projectId &amp;&amp; t.ActivityDate&gt;=startDate &amp;&amp; t.ActivityDate&lt;=endDate).ToList(); return dc.CurrentActivities.Where(t =&gt; t.User.RecId.ToString() == employeeId &amp;&amp; t.ActivityDate &gt;= startDate &amp;&amp; t.ActivityDate &lt;= endDate).ToList(); } </code></pre>
 

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