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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:21:18+00:00 2026-06-08T10:21:18+00:00

Just would like to know if its possible to do lazy loading without linq

  • 0

Just would like to know if its possible to do lazy loading without linq or an ORM. There are some queries I need to do that is inappropriate for ORMs. I will also need to pass the query between methods. Also, I could’t find any micro orms to achieve this. Is there any way to do this?

var q = "Select Name from Test1"

Now we must add an OR or AND or IN or something else

This query will be passed to different methods to be filtered. Is there a way to do this using a micro ORM or AD Hoc SQL Queries?

  • 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-08T10:21:19+00:00Added an answer on June 8, 2026 at 10:21 am

    One approach is to express the query as some sort of in-memory object that you can further add expressions to it. For example, using some made up object hierarchy:

    var q = Table("Test1").Select("Name");
    

    You would further refine this by adding filters:

    q = q.Where("ID= 1");
    

    But of course this means that you are re-inventing IQueryable. You would better just embrace LINQ then and choose a provider (LINQ2SQL or LINQ2EF etc).

    Another approach is to keep the string ad-hoc representation:

    var q = "Select Name from Test1";
    

    but then how do you add a filter? You have to parse the string and insert the WHERE clause. This is far from trivial. You would soon be implementing a fully fledged SQL parser (lex+yacc or bison+flex) and a abstract syntax tree, and then serialize this as a new SQL string. Once you start thinking about joins (fairly trivial to support), subqueries (nasty), recursive table expressions (ouch) things get progresively more complex. Just browse this very site and look at how complex SQL queries can get, and imagine implementig a parse for that.

    Many of projects I’ve seen tried to represent queries as some intermediate form, eg. a structure (list of fields, table name, list of WHERE conditions, list of ORDER BY clauses etc) and then add new entries in these list representation (Add a new entry in the WHERE list to add a new filter). But, in retrospect, these representations pale in comparison to what LINQ offers. I admit, LINQ is an all-or-nothing offering and you either commit yourself or not. But attempting to re-invent it only reveals the complexity of the problem. Today I would approach the problem from the other end: start with LINQ and try to keep it at bay, do not allow it to grow into a hideous monster of uncontrollable query generation tool in which every layer of the project adds some filter to the IQueryable and then bomb the server with something that no optimizer could even untangle.

    PS. Why I Wrote AREL is a good read on this whole problem.

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

Sidebar

Related Questions

I just would like to know if it is possible (and if yes how)
I would just like to know if there is any advantage to having a
I would like to know if its possible to get full screen snapshots from
I just would like to know what format and codec would use the least
I am just learning and would like to know about a piece of code
I am new to coding and would just like to know a bit more
I'm debugging multi-threaded code and I would just like to know if a line
I'm just learning Erlang with Chicago Boss and would like to know how could
Is there anything like this outside of the application delegate? I would just like
I would like to know if there is a fundamental reason for limiting the

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.