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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:22:29+00:00 2026-05-29T09:22:29+00:00

Have some code: using (var ctx = new testDataContext()) { var options = new

  • 0

Have some code:

using (var ctx = new testDataContext())
        {
            var options = new DataLoadOptions();
            options.LoadWith<TableA>(p => p.TableB);
            ...
            var tmp = ctx.TableA.Where(p => p.TableB != null);
            ...
        }

Want to wrap it like:

Action<T> test = x => {
    using (var ctx = new testDataContext())
        {
            var options = new DataLoadOptions();
            options.LoadWith<TableA>(p => typeof(x));
            ...
            var tmp = ctx.TableA.Where(p => p.GetType().GetProperty(x) != null);
            ...
        }
}
test(TableB);
test(TableC);

Or something like that.

The idea is – to use same method, for diffrent tables, which are passed as parameter, to some function.

I know about linq2sql inheritance, but i want to know, is it possible to do another way?

  • 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-29T09:22:30+00:00Added an answer on May 29, 2026 at 9:22 am

    If the particular property/properties you’re going to inspect are fixed in number and known at compile time, then adding a particular interface for those tables (via partial class, I’d assume) would likely be easiest and still type-safe. Otherwise, you’re looking at reflection, or using dynamic, or perhaps using Dynamic LINQ depending on the goals.

    Giving a more concrete example might help since it’s not clear to me whether it’s something you want to take specific tables that fit a pattern for, or any table no matter what.

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

Sidebar

Related Questions

Suppose I have the following: using(var ctx = DataContextFactory.Create(0)) { ... Some code ...
I have some code using a System.Transactions.TransactionScope , that creating a new instance of
I have the following code in my application: using (var database = new Database())
I have some code using Lucene that leaves the default conjunction operator as OR,
I have some code using libxml2's SAX2 interface. I want to be able to
Let's say I have some code (using CherryPy) that looks like this: import cherrypy
I have some code that is using SyncEnumerator. As you can see here ,
I have some code in .Net to draw some text content using GDI+. I
Suppose I have some code: let listB = [ 1; 2; 3 ] Using
I have a task and I want to generate some code using the CodeDom.

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.