Dev*_*ion 5 c# wcf entity-framework repository-pattern
在存储库中,最佳和最合乎逻辑的方法是什么?
使用实体删除还是按ID删除?
public void Delete(Entity item);
VS.
public void Delete(int Id);
Run Code Online (Sandbox Code Playgroud)
我只是想知道什么是最佳实践,应该通过Entity删除(在删除之前先找到对象即可实现)还是通过Id删除(在方法上搜索对象然后删除)。
AFAK 毕竟,如果您是您的实体,则选择第二个选择public void Delete(int Id);
是最佳实践,将根据此 ID 检索、更新或删除实体,此外,如果您将存储库公开为使用 int 调用服务,将会快速且不那么繁琐然后用实体调用ID
primary Key
WebService( e.g like WCF)
更新
此外,您可以向您的潜在客户添加两个世界都是断开连接的,并且模型上定义的实体在客户端将不相同,因为您可以向代理上的部分类添加属性,这只是会被SOAP envelope
解释在服务器端more the envelope is less in size more the communication is fast
Windows Communication Foundation (WCF) is an XML-based communications infrastructure. Because XML data is commonly encoded in the standard text format defined in the XML 1.0 specification, connected systems developers and architects are typically concerned about the wire footprint (or size) of messages sent across the network, and the text-based encoding of XML poses special challenges for the efficient transfer of binary data.
归档时间: |
|
查看次数: |
929 次 |
最近记录: |