WCF和Repository模式之间的区别 [英] Difference between WCF and Repository pattern

查看:123
本文介绍了WCF和Repository模式之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在wcf接口和类中



存储库模式使用接口和类



除了名称两者似乎是一样的。

是否已从存储库模式创建wcf?

In wcf Interface and classes
and
Repository pattern Using Interface and Classes

except names both are seems same.
Has wcf created from Repository pattern?

推荐答案

是否已从存储库模式创建wcf?

编号类/接口更像是面向对象的构造,在这种情况下是VB.Net或C#语言的东西,并且更常用。模式通常使用接口和类继承来工作,但不是专门用于存储库模式。



存储库模式可以概括为代理或外观psuedo-code中的数据访问层通常涉及包装CRUD操作:



Has wcf created from Repository pattern?
No. Classes/interfaces are more of a Object oriented construct, in this case a VB.Net or C# language thing and is in more general use. Often patterns make use of Interfaces and class inheritance to work, but not specifically to the repository pattern.

The repository pattern can be summed up as a proxy or facade around a data access layer in psuedo-code it would be typically involve wrappering CRUD operations:

public interface IRepository <T>
{
    public void Insert(T entity);
    public void Delete(T entity);
    //For reasons of usability, especially with LINQ the next to would return IQueryable<T>
    IEnumerable<T> GetAll();
    IEnumerable<T> Search(Expression<Func<T,bool>> predicate);
    T GetById(int id); //Assuming an int index..
    void Update(T updatedEntity)
}





使用LINQ你可能想要一个Save方法来提交更新,更新将是多余的,因为你可以做 GetById() - > [更新对象] - > Save()如果正确实现。

虽然WCF可能会暴露类似这些方法的东西(例如WCF数据服务 [ ^ ], REST WCF [ ^ ],甚至是手工制作的东西) - 这实际上是WCF的一个应用程序,而不是WCF是存储库模式的一个示例。



希望这有帮助。



With LINQ you'd probably want a Save method to commit updates, the Update would be redundant as you could then do a GetById() --> [update object] --> Save() if correctly implemented.
Though it is possible for WCF to expose something like these methods (e.g. WCF Data Services[^], REST WCF [^], or even something hand-rolled) - this is really one application of WCF, rather than WCF being an example of the repository pattern.

Hope this helps.


这篇关于WCF和Repository模式之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆