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 3677850
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:16:17+00:00 2026-05-19T03:16:17+00:00

Many thanks to leppie: Currently I got Expression<Func<vwMailMerge,bool>> whereClause= null; List<vwMailMerge> mailMergeItems = null;

  • 0

Many thanks to leppie:
Currently I got

Expression<Func<vwMailMerge,bool>> whereClause= null;
List<vwMailMerge> mailMergeItems = null;

int personType = mailMergeSettings.PersonType.ToInteger();
if (personType > 0)
{
    whereClause = this.MailMergeWhereClause(whereClause, f => f.MemberTypeId == personType);
}
if (mailMergeSettings.PersonIds != null)
{
    var personIds = mailMergeSettings.PersonIds.ToGuidArray();
    if (personIds != null && personIds.Length > 0)
    {
        var personList = personIds.ToList();
        whereClause = this.MailMergeWhereClause(whereClause, f => personList.Contains(f.UserId));
    }
}

mailMergeItems = this.ObjectContext.vwMailMerges.Where(whereClause).ToList();
private Expression<Func<vwMailMerge, bool>> MailMergeWhereClause(params Expression<Func<vwMailMerge, bool>>[] wheres)
{
    if (wheres.Length == 0)
    {
        return x => true;
    }
    Expression result;   
    if (wheres[0] == null)
    {
        result = wheres[1].Body;
        return Expression.Lambda<Func<vwMailMerge, bool>>(result, wheres[1].Parameters);
    }
    else
    {
        result = wheres[0].Body;
        for (int i = 1; i < wheres.Length; i++)
        {
            result = Expression.And(result, wheres[i].Body);
        }
        return Expression.Lambda<Func<vwMailMerge, bool>>(result, wheres[0].Parameters);
        }     
    }
}

When it gets to “mailMergeItems =” it drops and gives error: “The parameter ‘f’ was not bound in the specified LINQ to Entities query expression.”

I’ve noticed that when checking only for people, or only for membertypeId, it works properly.. but combined the 2nd gives a error on it’s “f=>” I think.

  • 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-05-19T03:16:17+00:00Added an answer on May 19, 2026 at 3:16 am

    You could reformat your question better with the code tool.

    However it looks like you could approach the problem in this way to avoid all those func expressions floating around:

    this.ObjectContext.vwMailMerges.Where(mm=>IsValidMailMerge(mm,personType)).ToList()
    
    
    private bool IsValidMailMerge(YourType mailmerge, YourType2 personType)
    {
    if(...) // type specific criteria here
    return true;
    else
    return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got many of my questions solved here, many thanks to you guys.
Okay, I've almost got this thing finished! Many thanks to all who have helped
Many thanks for the advice you have given me thus far. Using testbenches is
Following on from my earlier question about creating Address Books (many thanks Peter!), I
Well to me Perl sometimes looks abit Abracadabra so many thanks for the patience
many thanks for this site. many posts have helped me recently. this window question
How would I go about passing function parameters into a regex query? Many thanks.
How to use them in a ASP.NET Web Application project? Any difference? many thanks
Many thanks in advance. I'm working out of a schoolbook and they're using one
Hey first question I'm asking here many thanks in advance. I'm using a vector

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.