Answer the question
In order to leave comments, you need to log in
How to organize the right architecture with a WCF service in a three-tier project?
Started learning WCF. For my test project, I decided to make a three-tier project: 1) a class library with all the business logic and work with the database on LinqToSql; 2) WCF service library; 3) ASP.NET MVC client.
Actually, the snag arose in how best to organize the LinqToSql - WCF connection.
At the moment, the interfaces of my LinqToSql models are:
interface IVisitor
{
DateTime DateOfBirth { get; set; }
bool Gender { get; set; }
string Name { get; set; }
string Surname { get; set; }
System.Data.Linq.EntitySet<Visit> Visit { get; set; }
}
interface IVisit
{
DateTime DateVisit { get; set; }
long IdVisitor { get; set; }
Visitor Visitor { get; set; }
}
Answer the question
In order to leave comments, you need to log in
It is better to make separate classes with the same fields as in the linq2sql models, and inside the service implementation from the data contract, copy the fields to the corresponding model, for example, via AutoMapper.
public class MyService{
public IEnuberable<SVisit > GetAllVisitors(){
return dc.Visits.ToList().Select(Mapper.Map<SVisit>);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question