Пример #1
0
        // fails with "Resource not found for the segment 'CategoryPropertyValues'"
        public void DeleteCategoryPropertyValue_ExistingCategory()
        {
            var ServiceUri            = new Uri("http://localhost/store/DataServices/CatalogDataService.svc");
            ICatalogRepository client = new DSCatalogClient(ServiceUri, new CatalogEntityFactory(), null);
            var category1             = client.Categories
                                        .OfType <Category>()
                                        .Expand("CategoryPropertyValues")
                                        .First();

            var category = category1.DeepClone(new CatalogEntityFactory()) as Category;

            client = new DSCatalogClient(ServiceUri, new CatalogEntityFactory(), null);
            client.Attach(category);

            /*
             * var category = category1.DeepClone(new CatalogEntityFactory()) as Category;
             * client = new DSCatalogClient(ServiceUri, new CatalogEntityFactory());
             * client.Attach(category);
             *
             * //// adding: works
             * var item = new CategoryPropertyValue { IntegerValue = 1, Name = "unit tst", ValueType = PropertyValueType.Integer.GetHashCode() };
             * item.CategoryId = category.CategoryId;
             * client.Add(item);
             * category.CategoryPropertyValues.Add(item);
             * client.UnitOfWork.Commit();
             */

            // deleting: fails
            var item = category.CategoryPropertyValues[0] as CategoryPropertyValue;

            //client.Attach(item);
            client.Remove(item);
            category.CategoryPropertyValues.Remove((CategoryPropertyValue)item);
            client.UnitOfWork.Commit();
        }
Пример #2
0
        public T GetRepositoryInstance()
        {
            IPricelistRepository retVal = new DSCatalogClient(_service.ServiceUri, new CatalogEntityFactory(), null);

            return((T)retVal);
        }