I am new to setting up WCF, I have it going in my project, but I have like 5 different 'services' in my one WCF project and I am wondering if I am doing the right thing. My services for now are 1-1 to my database tables. I end up having something like:
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();
}
}
I have a similar class for each of the tables in my project. Should I be finding a way to use 1 service connection with sub classes or keep it as 1 service class per table?