示例#1
0
        public void Insert <T>(SsdsEntity <T> entity) where T : class
        {
            SsdsEntitySerializer <T> serializer = new SsdsEntitySerializer <T>();
            string         payload = serializer.Serialize(entity);
            SsdsRestFacade facade  = this.CreateFacade();

            facade.Insert(payload);
        }
示例#2
0
        /// <summary>
        /// Updates the item on the container.
        /// </summary>
        /// <param name="entity">The item with the information to be updated.</param>
        public void Update <T>(SsdsEntity <T> entity, ConcurrencyPattern concurrencyPattern) where T : class, new()
        {
            Uri                      updateLocation = HttpRestUriTemplates.UpdateTemplate.BindByPosition(this.authority, this.container, entity.Id);
            SsdsRestFacade           facade         = this.CreateFacade(updateLocation);
            SsdsEntitySerializer <T> serializer     = new SsdsEntitySerializer <T>();
            string                   payload        = serializer.Serialize(entity);

            facade.Update(payload, concurrencyPattern, entity.Version.ToString());
        }
示例#3
0
        /// <summary>
        /// Retrieves multiple object from the container when the match with a criteria.
        /// </summary>
        /// <param name="expression">The expression of the criteria used to determine which will be the object.</param>
        /// <returns>IEnumerable of T populated with data from Ssds.</returns>
        public IEnumerable <SsdsEntity <T> > Query <T>(Expression <Func <SsdsEntity <T>, bool> > expression) where T : class
        {
            SsdsRestFacade facade = this.CreateFacade();

            //since we are querying by kind... add it in
            expression = AddKindToExpression <T>(expression);

            SsdsExpressionVisitor translator = new SsdsExpressionVisitor();
            string criteria = translator.Translate(expression);

            var response = facade.Get(criteria);

            if (response == null)
            {
                return(null);
            }

            SsdsEntitySerializer <T>      serializer = new SsdsEntitySerializer <T>();
            IEnumerable <SsdsEntity <T> > items      = serializer.DeserializeMany(response);

            return(items);
        }
示例#4
0
        public IEnumerable <SsdsEntity <T> > GetEntities <T>() where T : class, new()
        {
            SsdsEntitySerializer <T> serializer = new SsdsEntitySerializer <T>();

            return(serializer.DeserializeMany(Response));
        }