本文整理汇总了C#中IDbContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# IDbContext.SaveChanges方法的具体用法?C# IDbContext.SaveChanges怎么用?C# IDbContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDbContext
的用法示例。
在下文中一共展示了IDbContext.SaveChanges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopularContexto
public static void PopularContexto(IDbContext contexto)
{
var segmentos = CriarSegmentos();
var servicos = CriarServicos(segmentos);
segmentos.ForEach(s => contexto.Segmentos.Add(s));
contexto.SaveChanges();
servicos.ForEach(s => contexto.Servicos.Add(s));
contexto.SaveChanges();
}
示例2: FakeDbContext
public void WhenPendingPaymentMessageWithEmailAddressRecipientUriProcessedWithKnownRecipientTwoTransactionsAreCreated()
{
Guid messageId = Guid.NewGuid();
Guid apiKey = Guid.NewGuid();
Guid senderId = Guid.NewGuid();
Guid senderAccountId = Guid.NewGuid();
_ctx = new FakeDbContext();
var application = _ctx.Applications.Add(new Domain.Application()
{
ApiKey = apiKey,
ApplicationName = "Test App",
IsActive = true,
Url = "http:\\test.paidthx.com"
});
var sender = _ctx.Users.Add(new Domain.User()
{
Application = application,
ApiKey = apiKey,
CreateDate = System.DateTime.Now,
EmailAddress = "[email protected]",
Limit = 100,
MobileNumber = "7082504915",
Password = "asdf",
PaymentAccounts = new System.Collections.ObjectModel.Collection<Domain.PaymentAccount>(),
IsConfirmed = true,
SecurityPin = "1234",
SetupPassword = true,
SetupSecurityPin = true,
UserStatus = Domain.UserStatus.Verified,
DeviceToken = "6b0bf548627aecffe1a87b3febf62c9f6eda50c35b6acce067a21b365dcc94b4"
});
var recipient = _ctx.Users.Add(new Domain.User()
{
Application = application,
ApiKey = apiKey,
CreateDate = System.DateTime.Now,
EmailAddress = "[email protected]",
Limit = 100,
MobileNumber = "8043879693",
Password = "asdf",
PaymentAccounts = new System.Collections.ObjectModel.Collection<Domain.PaymentAccount>(),
IsConfirmed = true,
SecurityPin = "1234",
SetupPassword = true,
SetupSecurityPin = true,
UserStatus = Domain.UserStatus.Verified,
DeviceToken = "6b0bf548627aecffe1a87b3febf62c9f6eda50c35b6acce067a21b365dcc94b4"
});
_ctx.SaveChanges();
var senderAccount = new Domain.PaymentAccount()
{
AccountNumber = "1234123412",
AccountType = Domain.PaymentAccountType.Checking,
IsActive = true,
CreateDate = System.DateTime.Now,
Id = senderAccountId,
NameOnAccount = "Chris Magee",
RoutingNumber = "053000219",
};
var recipientAccount = new Domain.PaymentAccount()
{
AccountNumber = "1010202030",
AccountType = Domain.PaymentAccountType.Savings,
IsActive = true,
CreateDate = System.DateTime.Now,
Id = senderAccountId,
NameOnAccount = "Chris Magee",
RoutingNumber = "053000211",
};
sender.PaymentAccounts.Add(senderAccount);
recipient.PaymentAccounts.Add(recipientAccount);
_ctx.SaveChanges();
var message = _ctx.Messages.Add(new Domain.Message()
{
Amount = 1,
Application = application,
ApiKey = apiKey,
Comments = "Test Payment",
CreateDate = System.DateTime.Now,
Id = messageId,
MessageStatus = Domain.MessageStatus.Pending,
MessageType = Domain.MessageType.Payment,
RecipientUri = "[email protected]",
Sender = sender,
SenderId = senderId,
SenderAccount = senderAccount,
SenderAccountId = senderAccountId,
SenderUri = "7082504915",
Transactions = new System.Collections.ObjectModel.Collection<Domain.Transaction>(),
});
//.........这里部分代码省略.........
示例3: Update
/// <summary>
/// Update the properties recursive (mapped to root)
/// </summary>
/// <param name="root">the new values to update with</param>
public void Update(IDbContext context, ApiRoot root)
{
this.Uid = root.Player.Uid;
this.Name = root.Player.Name;
this.AllianceId = root.Player.AllianceId;
this.Tribe = root.Player.Tribe;
this.Server = root.Player.Server;
if (root.Villages != null)
{
// remove and replace the villages (they may have been lost or new ones built)
context.Villages.RemoveRange(this.Villages);
context.SaveChanges();
this.Villages = root.Villages;
}
}