c# - How to decouple objects in MVC Web API service and apps which uses it? -


i've finished working on mvc web api service, purpose show data microsft analysis cube, , return json objects.

so lets have object loaded cube , returned service json:

public class person{  public string name {get;set;}  public double balance {get;set;} } 

now on mvc app makes request service create exact same class, can desirealize json. can see if person object extended lastname atribute, have add exact same attribute in app too. there architecturs / patterns avoid creating exact same class/object on both app , webservice?

maybe create separate library contains nessesary objects, , parse in dll webservice , app? or there other way?

@ahmed right. should create separate models or view models expose data per tier. there security implications when overpost data endpoints. data may highly confidential salary, example, , show in wrong places. may use automapper map data between tiers. looks @ least addresses problem trying solve:

https://github.com/automapper/automapper


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -