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


C# DbSet.Remove方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:Tjitse,项目名称:sogeti.capstone,代码行数:7,代码来源:CapstoneContext.cs

示例2: ClearDatabase

 private void ClearDatabase(DbSet<CoffeeShop> coffeeShops)
 {
     foreach (var shop in coffeeShops)
     {
         coffeeShops.Remove(shop);
     }
 }
开发者ID:swegner,项目名称:coffee-map,代码行数:7,代码来源:CoffeeScraper.cs

示例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);
            }
        }
开发者ID:MulderFox,项目名称:Main,代码行数:52,代码来源:ConfigurationSeed.cs

示例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);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:DbSetTests.cs


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