3

What is the best way to go about syncing the server poco/dto object definitions in my spa application? so if i have a class with a list of address then on client we would like to have an object template that we can use to create an address instance to insert into the address list. Obviously our object graph is much larger and changes a lot during development so keeping such things in sync by hand is not a winning solution.

c# dto class

puclic class dto{
dto()
{
 addressList = new List<address>();
}
 puclic List<address> addresses {get;set;}
 public string otherField{get;set;}
}

public class address{
 public string street{get;set;}
 public string city {get;set;}
}

javascript objects

var AddressClass = function(){
 this.street ="";
 this.city = "";
};

var Dto = function(){
 this.addressList = [];
 this.otherField = "";
};

some where in scope add to the addressList array

$scope.dtoClass.AddressList.push (new AddressClass() );

so the goal is an address class on the server and an addressClass on the client.

2
  • You can use JSON serializer. Commented Apr 1, 2014 at 18:48
  • it's not a serialization issue. It's having the same anemic objects on the client and server Commented Apr 1, 2014 at 22:17

1 Answer 1

2

sharp2Js is a small library that can create javascript objects that mirror your C# POCO classes and can be easily used to generate js files using T4 templates

Here is the url on github https://github.com/castle-it/sharp2Js

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.