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

  • Home
  • SEARCH
  • 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 8989643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:18:41+00:00 2026-06-15T22:18:41+00:00

I have a small request object to filter by. public class BufferFlatViewFilter { public

  • 0

I have a small request object to filter by.

public class BufferFlatViewFilter
{
    public bool? Active { get; set; }
    public int? CustomerId { get; set; }
    public int? TypeId { get; set; }
}

And I need to build up the where filter for the db request.

With Entity framework I was able to build up the Where Statement like so.

public List<BufferFlatView> GetBufferFlatView(BufferFlatViewFilter filter)
{
    var data = db.qryCampaignOverView
        .AsQueryable();

    if (filter.TypeId.HasValue)
        data = data.Where(x => x.TypeId == filter.TypeId.Value);

    if (filter.CustomerId.HasValue)
        data = data.Where(x => x.CustomerId == filter.CustomerId);

    if (filter.Active)
        data = data.Where(x => x.Active == filter.Active);

    return data.ToList();
}

I’m not sure of how to build up the where statement for OrmLight given that Entity framework query is lazy loaded but not the OrmLight query.

  • 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-15T22:18:43+00:00Added an answer on June 15, 2026 at 10:18 pm

    We recently added expression chaining in the OrmLite ExpressionVisitor – code copy & pasted from the unit tests:

    var visitor = dbConnection.CreateExpression<Person>();
    visitor.Where(x => x.FirstName.StartsWith("Jim")).And(x => x.LastName.StartsWith("Hen"));
    var results = db.Select<Person>(visitor);
    Assert.AreEqual(1,results.Count);
    
    visitor.Where(x => x.Age < 30).Or(x => x.Age > 45);
    results = db.Select<Person>(visitor);
    Assert.AreEqual(5, results.Count);
    Assert.IsFalse(results.Any(x => x.FirstName == "Elvis"));
    

    Note: Where(x => predicate) and .And(x => predicate) are functionally the same.

    You can also build up your Order By expression

    visitor.OrderBy(x => x.Name).ThenByDescending(x => x.Age);
    

    So your code becomes

    public List<BufferFlatView> GetBufferFlatView(BufferFlatViewFilter filter)
    {
        //assumes IDbConnection instance injected by IOC
        var ev = dbConnection.CreateExpression<Campaign>();
    
        if (filter.TypeId.HasValue)
            ev.Where(x => x.TypeId == filter.TypeId.Value);
    
        if (filter.CustomerId.HasValue)
            ev.Where(x => x.CustomerId == filter.CustomerId);
    
        if (filter.Active)
            ev.Where(x => x.Active == filter.Active);
    
        return dbConnection.Select<Campaign>(ev);
    

    }

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

Sidebar

Related Questions

I'm writing a small ajax class for personal use. In the class, I have
I have one small issue with creating a new bean. Basically as per request,
I have a a view model that looks like. public class StoreItemViewModel { public
I have a small problem. I am testing my Android REST class on http://www.thomas-bayer.com/sqlrest/CUSTOMER
Once again I have a small problem to get this done in django. But
I have a small python app running via uwsgi with requests served by nginx.
have small problem, and would very much appreciate help :) I should convert byte
I have small query today I happen to see when I typed a website
I have small question by entity framework 4.1. There is interface of image DTO:
I have small script in bash, which is generating graphs via gnuplot. Everything works

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.