当前位置: 首页>>代码示例>>C#>>正文


C# IRepository.Save方法代码示例

本文整理汇总了C#中IRepository.Save方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.Save方法的具体用法?C# IRepository.Save怎么用?C# IRepository.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRepository的用法示例。


在下文中一共展示了IRepository.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateRepository

 public void CreateRepository()
 {
     _repo = new UserRepository();
     _user1 = new User("admin","test");
     _repo.Save(_user1);
     _user2 = new User("razvan","1234");
     _repo.Save(_user2);
 }
开发者ID:tymysrazvan,项目名称:PersonalBugetC,代码行数:8,代码来源:UserRepositoryTests.cs

示例2: CreateRepository

 public void CreateRepository()
 {
     _repo = new ExpenseRepository();
     _exp1 = new Expense(TypeExpense.Car, 34, "euro");
     _exp2 = new Expense(TypeExpense.Eat, 45, "euro");
     _repo.Save(_exp1);
     _repo.Save(_exp2);
 }
开发者ID:tymysrazvan,项目名称:PersonalBugetC,代码行数:8,代码来源:ExpenseRepositoryTests.cs

示例3: when_implementing_base_repository

        public when_implementing_base_repository() 
        {
            RefreshDb();

            _repository = new DataProviderRepository(Session);
            var dataProvider = ReadDataProviderMother.Ivid;
            _repository.Save(dataProvider);
            _repository.Save(ReadDataProviderMother.Rgt);

            Session.Flush();

            _id = GetFromDb(dataProvider).Id;
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:13,代码来源:when_implementing_base_repository.cs

示例4: Common_CanDelete

        public void Common_CanDelete(IRepository<Product> db)
        {
            db.Save(new Product { ProductName = "Optimus", Category = "Autobots", MinimumPrice = 7 });

            var px = new Product { ProductName = "Bumble Bee", Category = "Autobots", MinimumPrice = 8 };
            db.Save(px);

            db.Save(new Product { ProductName = "Megatron", Category = "Decepticon", MinimumPrice = 9 });

            db.Delete(px.ProductId, px.RowVersion);

            Assert.AreEqual(7 + 9, db.All.Sum(x => x.MinimumPrice));
            Assert.AreEqual(null, db.Get(px.ProductId));
            Assert.AreEqual(2, db.All.Count());
        }
开发者ID:MichaelBuen,项目名称:ToTheEfnhX,代码行数:15,代码来源:TestTheIRepository.cs

示例5: Handle

        // Update course 
        public static CourseUpdate.Response Handle(IRepository repository, CourseUpdate.Request request)
        {
            var container = CourseFactory.CreatePartial(request.CommandModel.CourseID).Modify(request.CommandModel);
            var validationDetails = repository.Save(container);

            return new CourseUpdate.Response(validationDetails);
        }
开发者ID:extstopcodepls,项目名称:ContosoUniversity,代码行数:8,代码来源:CourseHandlers.cs

示例6: InitializeSetting

 private static Setting InitializeSetting(string settingName, IRepository repository)
 {
     var setting = new Setting { Name = settingName.Encrypt() };
     repository.Add<Setting>(setting);
     repository.Save();
     return setting;
 }
开发者ID:Celdorfpwn,项目名称:ASAP,代码行数:7,代码来源:ConfigFactory.cs

示例7: Handle

 public override void Handle(IRepository _repository)
 {
     var command = this;
     var order = _repository.GetOrder(command.OrderId);
     var products = order.Products.Add(_repository.GetProduct(command.ProductId));
     _repository.Save(order.With(products:products));
 }
开发者ID:wallymathieu,项目名称:ImmutableObjectGraph-studies,代码行数:7,代码来源:AddProductToOrder.cs

示例8: Main

        static void Main(string[] args)
        {
            IoC.Register();
            _repo = IoC.Resolve<IRepository>();

            var geos = _repo.Find<City>().ToList();
            Console.WriteLine(string.Format("{0} total cities...", geos.Count()));

            int i =0;
            foreach (var geo in geos)
            {
                if (geo.Geography.GetType() == typeof(NetTopologySuite.Geometries.MultiPoint))
                {
                    Console.WriteLine(string.Format("{0} is a MultiPoint...", geo.Name));
                    var point = new NetTopologySuite.Geometries.Point(geo.Geography.Coordinates.First());
                    geo.Geography = point;
                    _repo.Save<City>(geo);
                    _repo.SubmitChanges();
                    Console.WriteLine(string.Format("{0} updated to Point...", geo.Name));
                    i++;
                }
            }
            Console.WriteLine(string.Format("{0} total Cities updated...", i));
            Console.Read();
        }
开发者ID:robbygregory,项目名称:GeospatialIntro,代码行数:25,代码来源:Program.cs

示例9: Handle

        // Modify student
        public static StudentModify.Response Handle(IRepository repository, StudentModify.Request request)
        {
            var commandModel = request.CommandModel;
            var container = StudentFactory.CreatePartial(commandModel.ID).Modify(commandModel);
            var validationDetails = repository.Save(container);

            return new StudentModify.Response(validationDetails);
        }
开发者ID:extstopcodepls,项目名称:ContosoUniversity,代码行数:9,代码来源:StudentHandlers.cs

示例10: SetupSettings

        /// <summary>Setups the basic settings.</summary>
        /// <param name="settingsRepository">The settings repository.</param>
        private static void SetupSettings(IRepository<Settings> settingsRepository)
        {
            var userRegistrationPrice = new Settings
            {
                _Key = USER_REGISTRATION_PRICE_KEY,
                Value = "50"
            };

            var vendorRegistrationPrice = new Settings
            {
                _Key = VENDOR_REGISTRATION_PRICE_KEY,
                Value = "100"
            };

            settingsRepository.Save(userRegistrationPrice);
            settingsRepository.Save(vendorRegistrationPrice);
        }
开发者ID:eugenzyx,项目名称:Estates,代码行数:19,代码来源:Program.cs

示例11: SampleMethod

        private static void SampleMethod(IRepository<Product,int?> productRepository)
        {
            SessionProvider.RebuildSchema();

            //Create a Product
            var pNew = new Product { ProductName = "Canned Salmon" };
            productRepository.Save(pNew);

            //Get a Product
            var pGet = productRepository.GetById(pNew.ProductId);

            //Update a Product
            pGet.ProductName = "Canned Tuna";
            productRepository.Save(pGet);

            //Delete a Product
            productRepository.Delete(pNew);
        }
开发者ID:johnnonolan,项目名称:HelloNHibernate,代码行数:18,代码来源:Program.cs

示例12: SetUp

        public void SetUp()
        {
            _repository = new MockRepository();

            _developer = new Developer() { Username = "jchadwick" };

            _calculators = new[] { new DefaultAchievementCalculator(_repository) };

            _repository.Save(_developer);
        }
开发者ID:jchadwick,项目名称:developer-achievements,代码行数:10,代码来源:DefaultAchievementCalculatorTests.cs

示例13: setup

        public virtual void setup()
        {
            var mongoRepository = new MongoRepository("blogspecs");
            mongoRepository.DeleteCollection<BlogSettings>();
            mongoRepository.DeleteCollection<Post>();

            _repository = mongoRepository;

            _blog = new BlogSettings
            {
                VirtualMediaPath = ""
            };
            _repository.Save(_blog);

            _fakePost = Post.CreatePost("Hello world", "", "BjartN", null);

            _repository.Save(_fakePost);

            _api = new  Infrastructure.MetaWeblogApi.MetaWeblog(_repository, new FakeUrlContext(),new FakeAuthenticationService());
        }
开发者ID:BjartN,项目名称:Blog,代码行数:20,代码来源:MetaWeblogContext.cs

示例14: InitializeTestClass

        public static void InitializeTestClass(TestContext testContext)
        {
            if (Directory.Exists(Configuration.PERSITS_VIRTUAL_FILE_PATH))
            {
                Directory.Delete(Configuration.PERSITS_VIRTUAL_FILE_PATH, true);
            }

            Application.Current.SetApplicationAssembly(Assembly.GetExecutingAssembly());
            repository = new DefaultRepository(fileStoreService, cacheStoreService);

            repository.Save(RepositoryTests.GetContentTypeCollection());
        }
开发者ID:mchound,项目名称:LewCMS,代码行数:12,代码来源:RepositoryTests.cs

示例15: Handle

        public static CountryCreate.Response Handle(IRepository repository, CountryCreate.Request request)
        {
            var validationDetails = Validator.ValidateRequest(request);
            if (validationDetails.HasValidationIssues)
                return new CountryCreate.Response(validationDetails: validationDetails);

            var country = new Country(request.CommandModel.Name, request.CommandModel.Population);
            repository.Add(country);
            repository.Save();

            return new CountryCreate.Response(country.Id);
        }
开发者ID:j-kelly,项目名称:GalaxiaUniversity-Template,代码行数:12,代码来源:CountryHandlers.cs


注:本文中的IRepository.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。