Entity Framework 4.1 Code First learning path (2)

Source: Internet
Author: User

Series of html ">PreviousIt was a long time ago. = during this period, the RTW of EF 4.1 has come out, and the Alpha of NH 3.2 has been 2... In fact, I am not lazy, and I have been using EF 4.1 at work. This is mainly because the last promised Update function is not fixed =

In short, this time's goal is

  • Implement a complete IRepository (adding, adding, deleting, and modifying capabilities)
  • Inheritance of domain objects
  • Things

First, let's look at IRepository

My interfaces are as follows:

   1: public interface IRepository<TEntity>
   2:     where TEntity : IEntity
   3: {
   4:     IEnumerable<TEntity> FindAll();
   5:     TEntity FindById(int id);
   6:     void Add(TEntity entity);
   7:     void Delete(TEntity entity);
   8:     void Update(TEntity entity);
   9: }

It should be regarded as the most basic warehousing interface.

The first few interfaces are well implemented. The DbSet object mentioned last time provides corresponding interfaces for direct calls. The code is similar to this.

   1: protected DbSet<TEntity> DbSet
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.