示例#1
0
        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()
            });
        }
示例#2
0
        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()
            });
        }
示例#3
0
        public void ById(string id)
        {
            if (id == null)
            {
                return;
            }

            if (_ids == null)
            {
                _ids = new[] { id }
            }
            ;

            if (_session.IsLoadedOrDeleted(id))
            {
                return;
            }

            _idsToCheckOnServer.Add(id);
        }
示例#4
0
        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);
        }
示例#5
0
        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()
            });
        }