本文整理汇总了C#中DbSet.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# DbSet.Remove方法的具体用法?C# DbSet.Remove怎么用?C# DbSet.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbSet
的用法示例。
在下文中一共展示了DbSet.Remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveDbSetData
private void RemoveDbSetData(DbSet set)
{
foreach (var @entity in set)
{
set.Remove(@entity);
}
}
示例2: ClearDatabase
private void ClearDatabase(DbSet<CoffeeShop> coffeeShops)
{
foreach (var shop in coffeeShops)
{
coffeeShops.Remove(shop);
}
}
示例3: FixBankAccountsAndMeetings
private static void FixBankAccountsAndMeetings(ref DbSet<BankAccount> bankAccountSet, ref DbSet<Meeting> meetingSet)
{
Meeting[] meetings = meetingSet.Where(m => m.Finished > DateTime.Now).ToArray();
BankAccount[] bankAccounts = bankAccountSet.Where(ba => ba.Token != "V2-1-0-21").ToArray();
foreach (Meeting meeting in meetings)
{
BankAccountType bankAccountType;
switch (meeting.MeetingType)
{
case MeetingType.Lgs:
case MeetingType.WorkshopyBi:
case MeetingType.Leaders:
case MeetingType.MspEvening:
bankAccountType = BankAccountType.LgsOrMspEveningOrWorkshopsOrLeaders;
break;
case MeetingType.SetkaniTymu:
bankAccountType = BankAccountType.TeamMeeting;
break;
case MeetingType.SkoleniDavidaKotaska:
bankAccountType = BankAccountType.DavidKotasekTraining;
break;
case MeetingType.Ostatni:
bankAccountType = BankAccountType.Others;
break;
default:
throw new ArgumentOutOfRangeException();
}
BankAccount bankAccount = bankAccounts.FirstOrDefault(ba => ba.CurrencyType == CurrencyType.CZK && ba.BankAccountType == bankAccountType);
if (bankAccount == null)
continue;
meeting.BankAccountId = bankAccount.BankAccountId;
}
bankAccounts = bankAccountSet.Where(ba => ba.Title == String.Empty && ba.Token != "V2-1-0-21").ToArray();
foreach (BankAccount bankAccount in bankAccounts)
{
bankAccount.Title = bankAccount.BankAccountTypeLocalizedText;
bankAccount.Owner = bankAccount.BankAccountTypeLocalizedText;
}
bankAccounts = bankAccountSet.Where(ba => ba.Token == "V2-1-0-21").ToArray();
foreach (BankAccount bankAccount in bankAccounts)
{
bankAccountSet.Remove(bankAccount);
}
}
示例4: Generic_DbSet_Remove_returns_the_added_entity
public void Generic_DbSet_Remove_returns_the_added_entity()
{
var set = new DbSet<FakeEntity>(new Mock<InternalSetForMock<FakeEntity>>().Object);
var entity = new FakeEntity();
var retVal = set.Remove(entity);
Assert.Same(entity, retVal);
}