I am building a basic (my first) Azure Mobile Service with Table Storage to manage a simple Events application. My DataObjects consist of 2 types of objects: Coordinatorand Event, I want the coordinators to be a separate table for storing certain information, which I do not want to denormalize inside events, but the events also have an internal object. A place to store details for the location of the event, but I want to keep it denormalized, because I do not want to maintain this information separately from the event.
Here are the objects that I have: DataObjests:
public class Coordinator : EntityData {
public string Name { get; set; }
public int Points { get; set; }
public bool IsActive { get; set; }
}
public class Event: EntityData {
public Coordinator Coordinator { get; set; }
public DateTime EventDate { get; set; }
public int Attendees { get; set; }
public Location Location { get; set; }
}
public class Location {
public string Name { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string County { get; set; }
public string PostCode { get; set; }
}
TableController, VS-, , , , MobileServiceContext , Post , :
public class EventController : TableController<Event> {
private MobileServiceContext context;
protected override void Initialize(HttpControllerContext controllerContext) {
base.Initialize(controllerContext);
context = new MobileServiceContext();
DomainManager = new EntityDomainManager<Event>(context, Request, Services);
}
protected override void Dispose(bool disposing) {
context?.Dispose();
base.Dispose(disposing);
}
public IQueryable<Event> GetAllEvent() {
return Query();
}
public async Task<IHttpActionResult> PostEvent(Event item) {
var coordinator = context.Coordinators.Find(item.Coordinator.Id);
item.Coordinator = coordinator;
Event current = await InsertAsync(item);
return CreatedAtRoute("Tables", new { id = current.Id }, current);
}
}
, , :
ID Name Points IsActive Version CreatedAt UpdatedAt Deleted
cdf96b0f93644f1e945bd16d63aa96e0 John Smith 10 True 0x00000000000007D2 04/09/2015 09:15:02 +00:00 04/09/2015 09:15:02 +00:00 False
f216406eb9ad4cdcb7b8866fdf126727 Rebecca Jones 10 True 0x00000000000007D4 04/09/2015 09:15:30 +00:00 04/09/2015 09:15:30 +00:00 False
, :
Id EventDate Attendees Location_Name Location_Address1 Location_Address2 Location_City Location_County Location_PostCode Version CreatedAt UpdatedAt Deleted Coordinator_Id
961abbf839bf4e3481ff43a214372b7f 04/11/2015 09:00:00 0 O2 Arena Peninsula Square London SE10 0DX 0x00000000000007D6 04/09/2015 09:18:11 +00:00 04/09/2015 09:18:11 +00:00 False cdf96b0f93644f1e945bd16d63aa96e0
, 2 Get of the Event, Coordinator Location , Json EventController Get - :
[{"id":"961abbf839bf4e3481ff43a214372b7f","attendees":0,"eventDate":"2015-11-04T09:00:00Z"}]
, 2 :
1) Location EventController , , , , Json, ( WebApiConfig) , , , MaxDepth, Location .
2) , , ( ), , , , .
, ?