Thanks. I'll give that a try. It sounds right, it's just different
than what I'm used to.
Coming from a WCF services background, I'm used to thinking of the
service (not the DTO) as the first class citizen. I'll have to get
used to this new way of thinking.
In my current project (following DDD), an Employee would be an entity
in the domain layer, which gets persisted back to the database through
a repository. So I have a DTO layer that contains things like
EmployeeDto. The DTO layer is set up as with linked projects, dual-
compiled for regular .Net and for Silverlight. So when I call the
EmployeeService with something like GetEmployeeByID(int ID), then I
would return an EmployeeDto so it can be serialized, sent down the
wire, and deserialized to the same DTO in the Silverlight client. The
EmployeeDto naming convention was to separate them from the Employee
entities. We use AutoMapper to bind them.
So if I'm understanding correctly, I'll want two DTOs now, one for
requests and one for responses. I'm a bit fuzzy on why the response
would be called EmployeeResponse. Let's consider the use case of
searching for an employee by name and active/inactive status. In the
past, I'd write a web service that would be something like
GetEmployee(string name, bool isActive). The name could be a partial
search string. I might have other ways of searching also, which is
why I included the isActive flag. Are you saying that I should just
have Employee and EmployeeResponse? It seems more natural to me that
I might have something like:
public class EmployeeRequest
{
public int? Id {get; set;}
public string Name {get; set;}
public bool? IsActive {get; set;}
... other possible search parameters ...
}
public class Employee
{
public int Id {get; set;}
public string Name {get; set;}
public string EmpNumber {get; set;}
public bool IsActive {get; set;}
}
That way I could look at non-nullable fields on the request and return
things accordingly. For example, if an Id was specified, then I'd
return one Employee, but if Id was null, I might return
IEnumerable<Employee>.
Then I would need the second service that you mentioned (routing via
post method helps, thanks!). It would take the Employee object and
perhaps return something like
public class EmployeeResponse
{
public bool Ok {get; set;}
}
Does this sound about right? Or maybe I've still got my head around
WCF ways of thinking about services...
BTW - I heard about ServiceStack while catching up on HanselMinutes
archives. Great interview! The timing couldn't be better, since I
was just about fed up with WCF and looking for alternatives. I will
try to contribute back as I can.
>
http://twitter.com/demisbellothttp://www.servicestack.net/mythz_blog- Hide quoted text -
>
> - Show quoted text -