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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:56:54+00:00 2026-06-15T09:56:54+00:00

If I have a common interface implemented by all entities, for example: public interface

  • 0

If I have a common interface implemented by all entities, for example:

public interface IEntity {
    int Id { get; set; }
    DateTime ValidFrom { get; set; }
    DateTime? ValidTo { get; set; }
}

Is it at all possible to filter out objects returned as part of a query if ValidTo is null – only return still valid objects.

Where I get this idea from is that Julia Lerman and Rowan Miller use something similar in PEF:DbContext to set state on disconnected entities, however they do it via the state manager which allows them to iterate through all entities which implement a particular interface – I want to do something similar, but on a query which involves sub-entities.

I am using SQL Server 2012, EF5 and .Net 4.5.

  • 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-15T09:56:54+00:00Added an answer on June 15, 2026 at 9:56 am

    The example you refer to relies on the ChangeTracker.Entries<T>() method that accepts an interface as generic type parameter. Of course this all happens in memory, there is no translation to SQL involved.

    When it comes to translating linq to SQL, entity framework does not (yet) support interfaces, basically because DbSet<T> must be based on a concrete class.

    Your only chance is to create a base type in stead of an interface and have your entities derive from that.

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

Sidebar

Related Questions

I made an Interface having all common methods a player should have. I implemented
Is it right by saying it's common to have some interface members not implemented
I have a small hierarchy of classes that all implement a common interface. Each
I have some common parts for all user control. It's defined in an interface,
I have a bunch of class who implement a common interface : Command. And
I have common functionality that I need to access from all screens of my
In C#, it's common to have methods like this: public IPerson GetPerson() { //
I have a set of classes that all need to be acted on in
I have an interface that is implemented by thirty concrete classes. The concrete implementers
I have an interface, e.g.: public interface Thing { FrobResult frob(FrobInput); } And several

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.