Note that there are some explanatory texts on larger screens.

plurals
  1. POusing variables in a dynamic linq query
    primarykey
    data
    text
    <p>I am using Linq to Entities and have added the using stmt of <code>using System.Linq.Dynamic;</code> My goal is to pass in the <code>whereClause</code> variable into the emailList query (see screen shot). </p> <p>Any thoughts? </p> <p><img src="https://i.stack.imgur.com/dIZv1.png" alt="Error message details"></p> <p>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br> After using @Michael suggestion I got it to work with the following: </p> <p>HTML (notice I placed the field value in 'Value' attr.): </p> <pre><code>&lt;asp:CheckBoxList ID="_checkboxGroups" runat="Server"&gt; &lt;asp:ListItem Text="Sid Dickens Lovers" Value="SidDickens_TF" Selected="False" /&gt; &lt;asp:ListItem Text="Rosamond Lover" Value="Rosamond_TF" Selected="false" /&gt; &lt;asp:ListItem Text="Wine and Cheese Lovers" Value="WineAndCheese_TF" Selected="false" /&gt; &lt;asp:ListItem Text="Good Clients" Value="IntDesign_TF" Selected="false" /&gt; &lt;asp:ListItem Text="Vendors" Value="Vendor_TF" Selected="false" /&gt; &lt;/asp:CheckBoxList&gt; </code></pre> <p>Code behind: </p> <pre><code>// determine # of items in asp:CheckBoxList var groupCount = _checkboxGroups.Items.Count; var conditions = new List&lt;string&gt;(); for (int i = 0; i &lt; groupCount; i++) { if (_checkboxGroups.Items[i].Selected) { conditions.Add(_checkboxGroups.Items[i].Value.ToString() + " == true"); } } string whereClause = string.Join(" OR ", conditions.ToArray()); ElanEntities3 db = new ElanEntities3(); var emailList = (from c in db.vEmailListViewforSendings orderby c.Email select c).AsQueryable(); emailList = emailList.Where(whereClause); _listViewClients.DataSource = emailList; </code></pre>
    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. 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