简体   繁体   English

设置什么 <TEntity> 在IDbSet接口中做什么?

[英]What does Set<TEntity> do in IDbSet interface?

I read an article about UOW in Entity Framework , it has some code like this: 我读了一篇关于Entity Framework UOW的文章,其中包含如下代码:

public interface IUnitOfWork
{
    IDbSet<TEntity> Set<TEntity>() where TEntity : class;
    int SaveChanges();
}

i really dont understand what does Set<TEntity>() do ? 我真的不明白Set<TEntity>()做什么的?

All entities are stored in a context with different flags (for example DELETED, CHANGED) in front of your database. 所有实体都存储在数据库前面的上下文中,该上下文带有不同的标志(例如DELETED,CHANGED)。 If SaveChanges will be called a synchronization with the database will be triggered. 如果将调用SaveChanges,则将触发与数据库的同步。 The Set contains all deleted and modified marked entities/database records inside a transaction. 该集合包含事务中所有已删除和已修改的标记实体/数据库记录。 If the transaction commit was successful the changes in all entities contained in the set will be visible; 如果事务提交成功,则该集中包含的所有实体的更改将可见。 if not a rollback will be started. 如果没有,将开始回滚。 It acts like a cache tracking all changes inside the target transaction. 它就像一个缓存,跟踪目标事务中的所有更改。 In this article a description of the UOW design pattern can be found ( http://www.codeproject.com/Articles/581487/Unit-of-Work-Design-Pattern ). 在本文中,可以找到有关UOW设计模式的描述( http://www.codeproject.com/Articles/581487/Unit-of-Work-Design-Pattern )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 包装DbSet <TEntity> 使用自定义DbSet / IDbSet? - Wrapping DbSet<TEntity> with a custom DbSet/IDbSet? 切换活动 <TEntity> -动态设置TEntity - ToggleActive<TEntity> - dynamically set TEntity IDbSet 和 DbSet 有什么区别? - What is the difference between IDbSet and DbSet? RemoveDataRecord <TEntity> (int id)-动态设置TEntity - RemoveDataRecord<TEntity>(int id) - dynamically set TEntity EF代码第一个IDbSet <TEntity> .Attach()已检测到关系_的角色_发生冲突的更改 - EF Code First IDbSet<TEntity>.Attach() Conflicting changes to the role _ of the relationship _ have been detected C#在“其中TEntity:类”上实现接口 - C# implement interface on “where TEntity : class” 我如何使用CreateObjectSet <TEntity> TEntity作为参数在哪里? - How do I use CreateObjectSet<TEntity> where TEntity as a parameter? 接口实现不提供async怎么办 - What to do when interface implementation does not provide async 转换列表<IInfrastructureEntity>列出<TEntity>其中泛型类型 TEntity 必须实现该接口 - Convert List<IInfrastructureEntity> to List<TEntity> where generic type TEntity necessarily implements that interface AutoResetEvent.Set()有什么作用? - What does AutoResetEvent.Set() do ?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM