GON*_*ale 3 .net activerecord linq-to-sql
我刚刚研究了ActiveRecord模式,基于此(http://en.wikipedia.org/wiki/Active_record_pattern),似乎Linq 2 Sql或多或少实现了这个,我错了吗?或者需要更改什么以使其符合ActiveRecord模式?
在某些方面,它可以感觉像一个活跃的记录模式,但事实并非如此.基本示例:
//load the entity
var c = myDataContext.Customers.FirstOrDefault(c => c.Id == 1876);
c.Name = "George Armstrong Custer";
// saves the entity
myDataContext.SubmitChanges();
Run Code Online (Sandbox Code Playgroud)
积极的记录
//load the entity
var c = Customer.GetCustomer(9);
c.Name = "Varus";
//save the entity
c.Save();
Run Code Online (Sandbox Code Playgroud)
活动记录实际上只涉及一个覆盖模型的类并提供数据接口Linq to Sql遵循不同的路径,其中有一些模型类和一个单独的数据接口,也称为存储库.
PS:有关使用活动记录模式的ORM的一个很好的示例,请查看Subsonic.
| 归档时间: |
|
| 查看次数: |
1604 次 |
| 最近记录: |