本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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));
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例12: SetUp
public void SetUp()
{
_repository = new MockRepository();
_developer = new Developer() { Username = "jchadwick" };
_calculators = new[] { new DefaultAchievementCalculator(_repository) };
_repository.Save(_developer);
}
示例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());
}
示例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());
}
示例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);
}