.net - Architecture of Azure Mobile Services Application -
i'm trying piece architecture windows universal app leveraging azure mobile services. it's lob app , need handle 100-250 offline\online tables. mobile services doesn't support nested complex objects on service side i've mapped of tables straight through entity framework.
the question have whether should use separate layer reconstitute dto's or if should doing through service layer , view model. main concerns isolation of responsibility (large team) , performance overhead additional mapping.
didn't have reputation add image here's link model.
an example person object collection of addresses attached. have 3 dto objects: 1 person 1 address , 1 many many relationship. if i'm mapping straight through view model i'd need addressing service lookup address specific person.
if insert "model" layer service returns person model collection of address on it. feels bit wrong though...
the right choice depends on how doing querying on client. in case, want querying on address directly, helpful have address table on client.
the reason doing mapping dtos said: there no direct support relationships between objects in azure mobile services. design ensure simple model interacting between client , server, can mean more design when data model involve relationships.
in general, advise following:
if have 1:many relationships there explicit ownership relationship between parent , children, best map child objects parent. simplifies case when mobile client creates new child objects , associates parent. offline sync protocol sends changes individually, objects must grouped if need 1 atomic action. example of this, see fieldengineerlite sample.
if have 1:many relationships , it's not important query on child objects directly, can either map in #1, or create separate table controllers children , manage mapping foreign keys.
for many:many relationships, adds complexity expose relationship table directly. here, consider flattening object ids 1 of objects. in example, customer dto have list of address ids, , addresses in own table on client.
if choose option #3, code needs make sure relevant addresses sent down client. either a) map flattened object , unpack on client side, or b) add clauses either client or server side query addresses client gets right data.
in case (b), should ensure changes address table pulled down before doing queries on customer table. case (b) easy implement if there query can done scope addresses pull down.
for instance, suppose building crm app customer assigned salesperson using app. then, join on customer , address , addresses belong customer owned logged in user.
Comments
Post a Comment