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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:05:23+00:00 2026-05-25T22:05:23+00:00

I started to implement a repository pattern following this tutorial . Now In the

  • 0

I started to implement a repository pattern following this tutorial. Now In the definition of the class which implements the interface of Repository. The defines of the classes are made like this.

public class Repository<E,C> : IRepository<E,C>, IDisposable 
    where E : EntityObject
    where C : ObjectContext
{
}

Can someone explain me if I defined a class with generics why do i need to type where to explain which are the objects that are expected??. I’m really confused with this topic

  • 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-25T22:05:24+00:00Added an answer on May 25, 2026 at 10:05 pm

    Constraining the types with where is a deliberate choice, which has two consequences:

    1. The compiler will not allow you to write code that instantiates the generic if the type parameters do not satisfy these constraints, and in return
    2. It will allow you to use objects of class E and C as EntityObject and ObjectContext within the definition of Repository<,>; otherwise, it would not let you access members (methods, properties, etc) of those classes because it wouldn’t be able to guarantee that those members exist on the types used to specify the generic.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement simple Event Bus I started like this: public class RegistrationData
I'm getting started in developing web services using JAX-WS. I'm trying to implement classes
I'm trying to get started with the repository pattern and ASP.NET MVC, and I
Question: I'm new to the repository pattern, and I'm attempting to implement a new
I just started working with PLINQO to implement the repository layer and the data
I´ve just started learning GWT and I´m trying to implement http://gwt.google.com/samples/Showcase/Showcase.html#!CwFileUpload and but failing
I started my project in Asp.net MVC(c#) & SQL Server 2005.I want to implement
Started with this question: OpenID. How do you logout OK. So OpenID does not
I started trying to implement drag-and-drop of virtual files (from a C# 4/WPF app)
I started to use the new ConcurrentDictionary from .Net4 to implement a simple caching

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.