我有一个通用的服务在数据库上执行CRUD操作,我会非常想公开为这样一个WCF服务属性:服务在WCF服务
[ServiceContract]
public interface ICrudService<T> where T : class
{
[OperationContract]
T Add(T arg);
// Read ...
// Update ...
// Delete ...
}
不幸的是WCF不支持泛型。
所以我想做出一个公开的其他服务属性,而不是一个WCF服务。像这样:
[ServiceContract]
public interface IService1
{
[OperationContract]
FooService FooService { get; }
[OperationContract]
BarService BarService { get; }
}
public interface ICrudService<T> where T : class
{
T Add(T arg);
// Read ...
// Update ...
// Delete ...
}
public class FooService : ICrudService<Foo>
{
}
public class BarService : ICrudService<Bar>
{
}
它不会让我使用服务作为操作合同。有其他方法可以实现吗?
这是我会严肃地质疑使用服务的价值。你为什么不能直接在数据库中调用你的数据库? –
我想允许从客户端调用操作。我有要求使用UWP应用程序作为客户端。 –