8
我是新來設置WCF,我有它在我的項目中,但我有一個WCF項目中有5個不同的'服務',我想知道如果我做正確的事情。我的服務現在是1-1我的數據庫表。我最終有類似的東西:WCF一個服務或多個服務
public class Projects : IProjects
{
public List<Project> GetAll()
{
return (from p in Connection.Data.Projects
select new Project {ID = p.id, Name = p.name}).ToList();
}
public Project GetByID(int id)
{
return (from p in Connection.Data.Projects
where p.id == id
select new Project {ID = p.id, Name = p.name}).First();
}
public Project AddProject(string name)
{
var project = new Data.Projects {name = name};
Connection.Data.AddToProjects(project);
Connection.Data.SaveChanges();
return new Project {ID = project.id, Name = project.name};
}
public void DeleteProject(int id)
{
var project = (from p in Connection.Data.Projects
where p.id == id
select new Project {ID = p.id, Name = p.name}).First();
Connection.Data.DeleteObject(project);
Connection.Data.SaveChanges();
}
}
我有我的項目中的每個表的類相似。我是否應該找到一種方法使用1個子類的服務連接,或者每個表保留1個服務類?
太棒了,謝謝你! – 2009-07-23 21:30:06