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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:49:06+00:00 2026-05-12T17:49:06+00:00

I am having a lot of fun with Linq2Sql. Expression Trees have been great,

  • 0

I am having a lot of fun with Linq2Sql. Expression Trees have been great, and just the standard Linq2Sql syntax has been a lot of fun.

I am now down to part of my application where I have to somehow store queries in a database, that are custom for different customers that use the same database and same tables (well, view, but you know what I mean). Basically, I cant hard-code anything, and I have to leave the query language clear text so someone can write a new where-clause type query.

So, if that description was harsh, let me clarify:

In a previous version of our application, we used to do direct SQL calls to the db using raw SQL. Yea. it was fun, dirty, and it worked. We would have a database table fulled of different criteria like

(EventType = 6 and Total > 0)

or a subquery style

(EventType = 7 
AND Exists (
    select * 
    from events as e1 
        where events.EventType = e1.EventType 
        and e1.objectNumber = 89)
    )

(sql injection anyone?)

In Linq2Sql, this is a little more challenging. I can make all these queries no problem in the CLR, but being able to pass dynamic where criterias to Linq is a little more challenging, especially if I want to perform a sub query (like the above example).

Some ideas I had:

Get the raw expression, and store it — but I have no idea how to take the raw text expression and reverse it back to executable to object expression.

Write a SQl like language, and have it parse the code and generate Linq Expression — wow, that could be a lot of fun

I am quite sure there is no SomeIqueryable.Where("EventType = 6 and Total > 54"). I was reading that it was available in beta1, but I don’t see how you can do that now.

var exp2 = context.POSDataEventView.Where("EmployeeNumber == @0", 8310); 

This would be the easiest way for me to deploy.. I think.

Store serialized Expressions — wow.. that would be confusing to a user trying to write a query — hell, I’m not sure I could even type it all out.

So, I am looking for some ideas on how I can store a query in some kind of clear text, and then execute it against my Linq2Sql objects in some fashion without calling the ExecuteSQL. I want to use the LinqObjects.

P.S. I am using pLinqo for this application if that helps. Its still linq2sql though.

Thanks in advance!

  • 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-12T17:49:06+00:00Added an answer on May 12, 2026 at 5:49 pm

    Perhaps the Dynamic LINQ Library (in the MSDN samples) would help?

    In particular, usage like:
    .Where("Category=2 And UnitPrice>3"

    This should work with any IQueryable<T> source – including LINQ-to-Objects simply by calling .AsQueryable() on the sequence (typically IEnumerable<T>).

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

Sidebar

Related Questions

so I'm having a lot of fun with Perl at home for some time
I am upgrading a Symfony website from 1.2.9 to 1.4.1 and having a lot
I'm new to Ruby on Rails and so far, I'm having a lot of
Just for fun I'm developing a native Win32 port of Mozilla XUL. XUL allows
I have lot of executable that I have compiled (long time back) for many
I have a sketch that I want to put up on my website, and
I installed VS 2008 Team System on a brand new Windows 7 installation, and
G'day, This is related to my question on star developers and to this question
When I was first started teaching myself programming, after finishing a tutorial I would

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.