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


C# ISession.Delete方法代码示例

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


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

示例1: SelectWithWhereClause

		public void SelectWithWhereClause()
		{
			using (session = OpenSession())
			{
				User user1 = new User();
				user1.UserName = "User1";
				session.Save(user1);

				User user2 = new User();
				user2.UserName = "User2";
				session.Save(user2);

				BlogPost post = new BlogPost();
				post.Title = "Post 1";
				post.Poster = user1;
				session.Save(post);

				session.Flush();
				session.Clear();

				User poster = (User) session.Get(typeof (User), user1.ID);

				string hql = "from BlogPost b where b.Poster = :poster";
				IList list = session.CreateQuery(hql).SetParameter("poster", poster).List();
				Assert.AreEqual(1, list.Count);
				BlogPost retrievedPost = (BlogPost) list[0];
				Assert.AreEqual(post.ID, retrievedPost.ID);
				Assert.AreEqual(user1.ID, retrievedPost.Poster.ID);

				session.Delete("from BlogPost");
				session.Delete("from User");
				session.Flush();
				session.Close();
			}
		}
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:35,代码来源:Fixture.cs

示例2: BaseViewModel

 public BaseViewModel(string pageName, ISession session)
 {
     CurrentPage = pageName;
     IsLoggedOn = session[SessionKeys.ACCESS_TOKEN] != null;
     ErrorFlash = session[SessionKeys.FLASH_ERROR] as string;
     SuccessFlash = session[SessionKeys.FLASH_SUCCESS] as string;
     GoogleAnalyticsKey = ConfigurationManager.AppSettings["GA_KEY"];
     session.Delete(SessionKeys.FLASH_ERROR);
     session.Delete(SessionKeys.FLASH_SUCCESS);
 }
开发者ID:runesoerensen,项目名称:Apphbify,代码行数:10,代码来源:BaseViewModel.cs

示例3: BaseViewModel

 public BaseViewModel(string pageName, ISession session)
 {
     CurrentPage = pageName;
     IsLoggedOn = session[SessionKeys.ACCESS_TOKEN] != null;
     ErrorFlash = session[SessionKeys.FLASH_ERROR] as string;
     SuccessFlash = session[SessionKeys.FLASH_SUCCESS] as string;
     GoogleAnalyticsKey = ConfigurationManager.AppSettings["GA_KEY"];    // TODO: Abstract settings and build a test for this value
     WebSiteSparkId = ConfigurationManager.AppSettings["WSS"];    // TODO: Abstract settings and build a test for this value
     session.Delete(SessionKeys.FLASH_ERROR);
     session.Delete(SessionKeys.FLASH_SUCCESS);
 }
开发者ID:nterry,项目名称:Apphbify,代码行数:11,代码来源:BaseViewModel.cs

示例4: DisbandTribe

 public virtual void DisbandTribe(ISession session)
 {
     if (this.Group == null && this.TribePermission != beans.TribePermission.Duke)
         return;
     foreach (TribeInvite invite in this.Group.Invites)
         session.Delete(invite);
     foreach (Player member in this.Group.Members)
     {
         member.Group = null;
         session.Update(member);
     }
     session.Delete(this.Group);
 }
开发者ID:DF-thangld,项目名称:web_game,代码行数:13,代码来源:Player.Methods.Tribe.cs

示例5: Init

        public void Init() {
            var builder = new ContainerBuilder();

            builder.RegisterModule(new ContentModule());
            builder.RegisterType<DefaultContentManager>().As<IContentManager>().SingleInstance();
            builder.RegisterType<StubCacheManager>().As<ICacheManager>();
            builder.RegisterType<Signals>().As<ISignals>();
            builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
            builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
            builder.RegisterInstance(new Mock<IContentDisplay>().Object);
            builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataProvider = "SqlCe" });
            builder.RegisterType<SqlCeStatementProvider>().As<ISqlStatementProvider>();
            builder.RegisterType<MySqlStatementProvider>().As<ISqlStatementProvider>();
            builder.RegisterType<PostgreSqlStatementProvider>().As<ISqlStatementProvider>();

            builder.RegisterType<AlphaPartHandler>().As<IContentHandler>();
            builder.RegisterType<BetaPartHandler>().As<IContentHandler>();
            builder.RegisterType<GammaPartHandler>().As<IContentHandler>();
            builder.RegisterType<DeltaPartHandler>().As<IContentHandler>();
            builder.RegisterType<EpsilonPartHandler>().As<IContentHandler>();
            builder.RegisterType<LambdaPartHandler>().As<IContentHandler>();
            builder.RegisterType<FlavoredPartHandler>().As<IContentHandler>();
            builder.RegisterType<StyledHandler>().As<IContentHandler>();
            builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
            builder.RegisterType<ShapeTableLocator>().As<IShapeTableLocator>();
            builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();

            builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));

            builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
            builder.RegisterInstance(new Mock<IPageClassBuilder>().Object); 
            builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();

            _session = _sessionFactory.OpenSession();
            builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();

            _session.Delete(string.Format("from {0}", typeof(GammaRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(DeltaRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(EpsilonRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(LambdaRecord).FullName));
            
            _session.Delete(string.Format("from {0}", typeof(ContentItemVersionRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(ContentItemRecord).FullName));
            _session.Delete(string.Format("from {0}", typeof(ContentTypeRecord).FullName));
            _session.Flush();
            _session.Clear();

            _container = builder.Build();
            _manager = _container.Resolve<IContentManager>();

        }
开发者ID:Higea,项目名称:Orchard,代码行数:51,代码来源:HqlExpressionTests.cs

示例6: UpdateFailureEmails

        private void UpdateFailureEmails(MimeDSNRecipient r, ISession session)
        {
            IList<AccountEmail> emails = session.CreateCriteria(typeof(AccountEmail))
                .Add(Expression.Eq("Address", r.FinalRecipientEmailAddress))
                .List<AccountEmail>();

            if (emails == null)
                return;

            foreach (AccountEmail email in emails)
            {
                if (IsStopping)
                    break;

                if (email.Failed)
                    continue;

                EventLogManager.WriteEntry(string.Format("Marked {0} [{1}] (id:{2}) with failure [{3}].",
                    email.Account.Name, email.Address, email.Id, r.DiagnosticCode));

                // check whether there're pending invitations for this e-mail
                foreach (AccountEmailConfirmation confirmation in Collection<AccountEmailConfirmation>.GetSafeCollection(email.AccountEmailConfirmations))
                {
                    session.Delete(confirmation);
                }

                email.Failed = true;
                email.LastError = r.DiagnosticCode;
                email.Modified = DateTime.UtcNow;
                session.Save(email);
                session.Flush();
            }
        }
开发者ID:dblock,项目名称:sncore,代码行数:33,代码来源:SystemSMTPMessageService.cs

示例7: SetDiplomacy

        public virtual void SetDiplomacy(Group tribe, TribeDiplomate diplomacy, ISession session)
        {
            if ((this.TribePermission & TribePermission.DiplomateOfficer) != TribePermission.DiplomateOfficer)
                return;
            if (this.Group == tribe)
                return;

            if (diplomacy == TribeDiplomate.NoRelation)
            {
                object[] objects = { this.Group, tribe };
                NHibernate.Type.IType[] types = { NHibernate.NHibernateUtil.GuessType(typeof(Group)), NHibernate.NHibernateUtil.GuessType(typeof(Group)) };
                session.Delete(" from TribeRelation r where r.CurrentTribe=:current and r.DiplomaticTribe=:tribe", objects, types);
                return;
            }

            TribeRelation oldRelation = (from tribeRelation in session.Linq<TribeRelation>()
                                         where tribeRelation.CurrentTribe == this.Group
                                         && tribeRelation.DiplomaticTribe == tribe
                                         select tribeRelation).SingleOrDefault<TribeRelation>();

            if (oldRelation != null)
                return;

            TribeRelation relation = new TribeRelation();
            relation.CurrentTribe = this.Group;
            relation.DiplomaticTribe = tribe;
            relation.Diplomacy = diplomacy;
            session.Save(relation);
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:29,代码来源:Player.Methods.Tribe.cs

示例8: QueryUsingReadonlyProperty

		public void QueryUsingReadonlyProperty()
		{
			using (session = OpenSession())
			{
				Nums nums1 = new Nums {ID = 1, NumA = 1, NumB = 2};
				session.Save(nums1);

				Nums nums2 = new Nums {ID = 2, NumA = 2, NumB = 2 };
				session.Save(nums2);

				Nums nums3 = new Nums {ID = 3, NumA = 5, NumB = 2 };
				session.Save(nums3);

				session.Flush();
				session.Clear();

				var nums = session.CreateQuery("from Nums b where b.Sum > 4").List<Nums>();

				Assert.That(nums.Count, Is.EqualTo(1));
				Assert.That(nums[0].Sum, Is.EqualTo(7));

				session.Delete("from Nums");
				session.Flush();
				session.Close();
			}
		}
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:26,代码来源:Fixture.cs

示例9: ChangeCommitted

        internal static bool ChangeCommitted(this ISessionPersistentObject al,CRUD Operation, IImportContext iic,  ISession session)
        {
            if (al == null)
                throw new Exception("Algo Error");

            bool needtoregister = false;

            IObjectStateCycle oa = al;

            switch (Operation)
            {
                case CRUD.Created:
                    needtoregister = true;
                    session.Save(al);
                    break;

                case CRUD.Update:
                    session.Update(al);         
                    oa.HasBeenUpdated();
                    break;

                case CRUD.Delete:
                    session.Delete(al);
                    oa.SetInternalState(ObjectState.Removed,iic);
                    break;
            }

            al.Context = null;

            return needtoregister;
        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:31,代码来源:ISessionObjectExtension.cs

示例10: Init

        public void Init() {
            _session = _sessionFactory.OpenSession();
            foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
                foreach (var killRecord in _session.CreateCriteria(killType).List()) {
                    _session.Delete(killRecord);
                }
            }
            _session.Flush();
            _session.Close();
            _session.Dispose();
            _session = _sessionFactory.OpenSession();

            var builder = new ContainerBuilder();
            builder.RegisterAutoMocking();
            builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
            builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
            builder.RegisterType(typeof(SettingsFormatter)).As(typeof(ISettingsFormatter));
            builder.RegisterType<Signals>().As<ISignals>();
            builder.RegisterType<StubCacheManager>().As<ICacheManager>();
            builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();

            _session = _sessionFactory.OpenSession();
            builder.RegisterInstance(_transactionManager = new TestTransactionManager(_session)).As<ITransactionManager>();

            _container = builder.Build();

        }
开发者ID:Golone,项目名称:Orchard,代码行数:27,代码来源:ContentDefinitionManagerTests.cs

示例11: Init

        public void Init() {
            var builder = new ContainerBuilder();
            builder.RegisterAutoMocking();
            builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
            builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
            builder.RegisterType(typeof(SettingsFormatter))
                .As(typeof(IMapper<XElement, SettingsDictionary>))
                .As(typeof(IMapper<SettingsDictionary, XElement>));
            builder.RegisterType<Signals>().As<ISignals>();
            builder.RegisterType<StubCacheManager>().As<ICacheManager>();
            builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();

            _container = builder.Build();

            _container.Mock<ISessionLocator>()
                .Setup(x => x.For(It.IsAny<Type>()))
                .Returns(() => _session);

            _session = _sessionFactory.OpenSession();
            foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
                foreach (var killRecord in _session.CreateCriteria(killType).List()) {
                    _session.Delete(killRecord);
                }
            }
            _session.Flush();
        }
开发者ID:rupertwhitlock,项目名称:IncreasinglyAbsorbing,代码行数:26,代码来源:ContentDefinitionManagerTests.cs

示例12: WebRepositoryFactory_CanCreateWebRepository

        public void WebRepositoryFactory_CanCreateWebRepository()
        {
            this.dataAccessLayer = new DataAccessLayer();
            this.session = this.dataAccessLayer.OpenSession();

            int newRepoId;
            IDictionary<string, string> sq;

            using (WebRepositoryFactory factory = new WebRepositoryFactory("this is a bad passphrase"))
            {

                sq = new Dictionary<string, string>() {
                    { "question1", "answer1" },
                    { "question2", "answer2" },
                    { "question3", "answer3" }
                };

                newRepoId = factory.CreateWebRepository(
                                WebRepositoryType.Tangerine,
                                "my test repository",
                                "https://www.tangerine.ca/en/index.html",
                                "myuseraccountname",
                                "123456",
                                sq);
            }

            WebRepositoryData repo = this.session
                .Get<WebRepositoryData>(newRepoId);

            Assert.AreEqual(newRepoId, repo.Id);
            Assert.AreEqual("my test repository", repo.Name);
            Assert.AreEqual(WebRepositoryType.Tangerine, repo.Type);

            // check that data is encrypted.
            foreach (string key in repo.Configuration.SecurityQuestions.Keys)
            {
                Assert.IsFalse(sq.ContainsKey(key));
            }

            Assert.AreNotEqual(
                "myuseraccountname",
                repo.Configuration.Username);

            Assert.AreNotEqual(
                "123456",
                repo.Configuration.Password);

            using (ITransaction tx = session.BeginTransaction())
            {
                session.Delete(repo);
                tx.Commit();
            }

            this.session.Dispose();
            this.session = null;

            this.dataAccessLayer.Dispose();
            this.dataAccessLayer = null;
        }
开发者ID:scraswell,项目名称:web-repositories-tests,代码行数:59,代码来源:WebRepositoryFactoryTests.cs

示例13: RunCleanupMedia

 public void RunCleanupMedia(ISession session, ManagedSecurityContext sec)
 {
     session.Delete(string.Format(
         "FROM AccountFeedItemMedia media " +
         " WHERE media.Modified < '{0}'", DateTime.UtcNow.AddMonths(-1).ToString(
             DateTimeFormatInfo.InvariantInfo)));
     session.Flush();
 }
开发者ID:dblock,项目名称:sncore,代码行数:8,代码来源:SystemSyndicationService.cs

示例14: DeleteMappings

 public void DeleteMappings(ISession session)
 {
     foreach (Type type in this.Mappings)
     {
         session.Delete("from " + type.FullName);
     }
     session.Flush();
     session.Clear();
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:9,代码来源:AbstractFixture.cs

示例15: RemoveAuthenticationFor

        public static void RemoveAuthenticationFor(Auth0User auth0User, ISession session)
        {
            var userId = auth0User.Claims.Get(_config.UserIdentifier);

            if (session.ToList().Any(x => x.Key.Equals(_config.CookieName)))
            {
                session.Delete(_config.CookieName);
            }

            _users.Remove(userId);
        }
开发者ID:auth0,项目名称:Auth0.NancyFx.SelfHost,代码行数:11,代码来源:Auth0Authentication.cs


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