This question builds upon an earlier question (although off-topic) I asked yesterday. Please give it a read first.
OK - in my WCF REST project, I have been converting m
I might be mis-understanding things here, but what you're trying to do is backwards. You would first get your domain object, then convert to the DTO, then write the serialized DTO to the stream:
public virtual Stream GetGroupById(string id)
{
var user = UserRepository.GetUserById(id);
var dto = new Contracts.UserDto
{
Email = user.Email.ToString(),
Password = user.Password.ToString(),
UserId = user.UserId.ToString(),
UserName = user.UserName.ToString()
}
var serializer = new JavaScriptSerializer()l
var bytes = Encoding.UTF8.GetBytes(serializer.Serialize(dto));
return new MemoryStream(bytes);
}
The Stream being returned to the client will contain the JSON for the serialized DTO.