目前我正在创建一个必须连接到 DAL 的 WCF 服务,该 DAL 只需使用 ADO.net 和存储过程连接到数据库。
DAl 将其来自数据库的响应写入数据契约(Contract),该数据契约(Contract)通过服务通过线路传递给客户端。
我读到这可能是反模式“CRudy 接口(interface)”,但我不确定因为我正在共享数据契约(Contract)。
如果我使用的是反模式,任何人都可以建议一个更好的模式来用于我需要的行为吗?
最佳答案
好吧,关于 CRUDy 模式及其优缺点似乎存在一些争议。至少,我会调用一个服务接口(interface),让你编写这种代码来使用它作为反模式(如注释 here ):
service.CreateCustomer(c);
foreach(Group group in c.Groups)
service.AddCustomerToGroup(c.CustomerId, group.GroupId);
foreach(Person person in c.Contacts)
service.AddCustomerContact(c.CustomerId, person);
暴露 CRUDy 接口(interface)本身就不好吗?我不会这么说的。重要的是提供一个接口(interface)
关于wcf - 这是 Crudy 反模式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2452860/