【发布时间】:2010-09-21 17:09:31
【问题描述】:
我有一个名为 Client 的 EnityName,我需要它的集合名称 Clients,它必须是通用的,以便我可以从 EntityName 获取任何实体的 EntitySetName。它在 svc 文件中公开,但似乎不在服务代理类中。如果我能做到这一点,那么我可以有一个像这样的通用方法。
public void Add<T>(IEnumerable<T> entitySet)
{
var myService = GetServiceContext();
foreach (var entity in entitySet)
{
myService.AddObject(entity.GetType().Name -- NEEDS TO BE ENTITY SET NAME, entity);
}
myService.SaveChanges(SaveChangesOptions.Batch);
}
【问题讨论】: