public GetRequest CreateRequest(JsonOperationContext ctx) { var queryBuilder = new StringBuilder("?"); _includes.ApplyIfNotNull(include => queryBuilder.AppendFormat("&include={0}", include)); bool hasItems = false; foreach (var id in _ids) { if (_session.IsLoadedOrDeleted(id)) { _alreadyInSession.Add(id); } else { hasItems = true; queryBuilder.AppendFormat("&id={0}", Uri.EscapeDataString(id)); } } if (hasItems == false) { // no need to hit the server Result = _loadOperation.GetDocuments <T>(); return(null); } return(new GetRequest { Url = "/docs", Query = queryBuilder.ToString() }); }
public GetRequest CreateRequest(JsonOperationContext ctx) { var idsToCheckOnServer = _ids.Where(id => _session.IsLoadedOrDeleted(id) == false); var queryBuilder = new StringBuilder("?"); _includes.ApplyIfNotNull(include => queryBuilder.AppendFormat("&include={0}", include)); idsToCheckOnServer.ApplyIfNotNull(id => queryBuilder.AppendFormat("&id={0}", Uri.EscapeDataString(id))); return(new GetRequest { Url = "/docs", Query = queryBuilder.ToString() }); }
public void ById(string id) { if (id == null) { return; } if (_ids == null) { _ids = new[] { id } } ; if (_session.IsLoadedOrDeleted(id)) { return; } _idsToCheckOnServer.Add(id); }
public LoadOperation ById(string id) { if (id == null) { return(this); } if (_ids == null) { _ids = new[] { id } } ; if (_session.IsLoadedOrDeleted(id)) { return(this); } _idsToCheckOnServer.Add(id); return(this); }
public GetRequest CreateRequest(JsonOperationContext ctx) { var idsToCheckOnServer = _ids.Where(id => _session.IsLoadedOrDeleted(id) == false); var queryBuilder = new StringBuilder("?"); _includes.ApplyIfNotNull(include => queryBuilder.AppendFormat("&include={0}", include)); var hasItems = idsToCheckOnServer.ApplyIfNotNull(id => queryBuilder.AppendFormat("&id={0}", Uri.EscapeDataString(id))); if (hasItems == false) { // no need to hit the server Result = _loadOperation.GetDocuments <T>(); return(null); } return(new GetRequest { Url = "/docs", Query = queryBuilder.ToString() }); }