Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7862681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:14:21+00:00 2026-06-02T23:14:21+00:00

I am using Linq to Entities and have added the using stmt of using

  • 0

I am using Linq to Entities and have added the using stmt of using System.Linq.Dynamic;
My goal is to pass in the whereClause variable into the emailList query (see screen shot).

Any thoughts?

Error message details

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
After using @Michael suggestion I got it to work with the following:

HTML (notice I placed the field value in ‘Value’ attr.):

<asp:CheckBoxList ID="_checkboxGroups" runat="Server">
                            <asp:ListItem Text="Sid Dickens Lovers" Value="SidDickens_TF" Selected="False" />
                            <asp:ListItem Text="Rosamond Lover" Value="Rosamond_TF" Selected="false" />
                            <asp:ListItem Text="Wine and Cheese Lovers" Value="WineAndCheese_TF" Selected="false" />
                            <asp:ListItem Text="Good Clients" Value="IntDesign_TF" Selected="false" />
                            <asp:ListItem Text="Vendors" Value="Vendor_TF" Selected="false" />
                        </asp:CheckBoxList>

Code behind:

// determine # of items in asp:CheckBoxList
        var groupCount = _checkboxGroups.Items.Count;

        var conditions = new List<string>();

        for (int i = 0; i < 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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:14:22+00:00Added an answer on June 2, 2026 at 11:14 pm

    You use System.Linq.Dynamic http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

    var email = from c in db.MailListViewForSendings
                order by c.ID
                select c;
    
    // then you chain the Linq;
    email = email.Where("CategoryID=3");
    

    To use parameters:

    var email = from c in db.MailListViewForSendings
                order by c.ID
                select c;
    
    // then you chain the Linq;
    email = email.Where("CategoryID=@0", 3);
    

    UPDATE

    Don’t use StringBuilder, use List<string> instead, then concatenate it by string.Join:

    using System;
    
    using System.Collections.Generic;
    
    public class Test
    {
            public static void Main()
            {
                 var conditions = new List<string>();
                 conditions.Add("Lastname = 'Lennon'");
                 conditions.Add("Firstname = 'John'");
                 conditions.Add("Age = 40");
    
                 Console.WriteLine(string.Join(" OR ", conditions.ToArray() ));
            }
    }
    

    Output:

    Lastname = 'Lennon' OR Firstname = 'John' OR Age = 40
    

    Live test: http://ideone.com/EFhnA

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: 'Contains()' workaround using Linq to Entities? I am using the System.Linq.Dynamic library
Is it worth using System.Transactions.TransactionScope on Linq to Entities? On the MS documentation ,
I'm working on the following LINQ query: public void GetAuditRuleAgencyRecords(IEnumerable<Entities.AuditRule> rules) { using (LinqModelDataContext
I'm using linq to entities(EF). I have a constructor which takes 4 string parameters.
Possible Duplicate: 'Contains()' workaround using Linq to Entities? Using LINQ in C#, I have
For a website I'm doing we're using LINQ to Entities. I have been charged
I am using LINQ to EF and have the following LINQ query: var results
I've got a situation where I need to have my LINQ to Entities query
Using LINQ to Entities with Entity Framework and C#: I have a method that
For a project using LINQ to Entities 4.0, I have a setting in which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.