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


C# ISession.SaveOrUpdate方法代码示例

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


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

示例1: ShouldSaveApproval

 public ShouldSaveApproval(ISession session, ISpecimenBuilder fixture)
 {
     var person = fixture.Create<Person>();
     session.SaveOrUpdate(person);
     var approval = new Approval { Person = person };
     session.SaveOrUpdate(approval);
     _approvalId = approval.Id;
 }
开发者ID:ChrisMissal,项目名称:atxc,代码行数:8,代码来源:ShouldSaveApproval.cs

示例2: ShouldSavePersonWithCategories

 public ShouldSavePersonWithCategories(ISession session, PersonFactory personFactory, ISpecimenBuilder specimenBuilder)
 {
     var categories = specimenBuilder.CreateMany<CategoryField>(_count).ToList();
     var fake = specimenBuilder.Create<Person>();
     var person = personFactory.CreatePerson(fake.Name, fake.Email, fake.Bio, Location.SanMarcos, categories);
     session.SaveOrUpdate(person);
     _personId = person.Id;
 }
开发者ID:ChrisMissal,项目名称:atxc,代码行数:8,代码来源:ShouldSavePersonWithCategories.cs

示例3: ShouldSavePersonWithLinks

 public ShouldSavePersonWithLinks(ISession session, PersonFactory personFactory, ISpecimenBuilder specimenBuilder)
 {
     var links = specimenBuilder.CreateMany<LinkField>(_count).ToList();
     var fake = specimenBuilder.Create<Person>();
     var person = personFactory.CreatePerson(fake.Name, fake.Email, fake.Bio, Location.Georgetown, null, links);
     session.SaveOrUpdate(person);
     _personId = person.Id;
 }
开发者ID:ChrisMissal,项目名称:atxc,代码行数:8,代码来源:ShouldSavePersonWithLinks.cs

示例4: Save

		private static void Save(ISession session, GridWidget widget)
		{
			if (widget.Id != Guid.Empty && !session.Contains(widget))
				widget = session.Merge(widget);

			session.SaveOrUpdate(widget);
			session.Flush();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:8,代码来源:Fixture.cs

示例5: Save

		public void Save(ISession session, MovieDB_Movie obj)
		{
			// populate the database
			using (var transaction = session.BeginTransaction())
			{
				session.SaveOrUpdate(obj);
				transaction.Commit();
			}
		}
开发者ID:maz0r,项目名称:jmmserver,代码行数:9,代码来源:MovieDB_MovieRepository.cs

示例6: CreateCategories

 private IEnumerable<Category> CreateCategories(ISession session, params string[] categoryNames)
 {
     return categoryNames.Select(x =>
                                     {
                                         var cat = new Category(x);
                                         WithTransaction(session, () => session.SaveOrUpdate(cat));
                                         return cat;
                                     });
 }
开发者ID:antgerasim,项目名称:RealWorldMvc,代码行数:9,代码来源:DataFixture.cs

示例7: AddSomeProducts

 private void AddSomeProducts(ISession session, Category category, int count)
 {
     for (int i = 0; i < count; i++)
     {
         var product = new Product("Product " + i);
         category.AddProduct(product);
     }
     WithTransaction(session, () => session.SaveOrUpdate(category));
 }
开发者ID:antgerasim,项目名称:RealWorldMvc,代码行数:9,代码来源:DataFixture.cs

示例8: ShouldSavePersonWithLinksRemoved

 public ShouldSavePersonWithLinksRemoved(ISession session, PersonFactory personFactory, ISpecimenBuilder specimenBuilder, IContainer container)
 {
     _container = container;
     var links = specimenBuilder.CreateMany<LinkField>(_startCount).ToList();
     var fake = specimenBuilder.Create<Person>();
     var person = personFactory.CreatePerson(fake.Name, fake.Email, fake.Bio, Location.SanMarcos, null, links);
     session.SaveOrUpdate(person);
     _personId = person.Id;
 }
开发者ID:ChrisMissal,项目名称:atxc,代码行数:9,代码来源:ShouldSavePersonWithLinksRemoved.cs

示例9: Person_should_have_and_remove_some_Categories

        public void Person_should_have_and_remove_some_Categories(ISession session)
        {
            var person = session.Get<Person>(_personId);

            person.Categories.Count.ShouldBe(_startCount);

            person.RemoveCategory(person.Categories.First());
            person.RemoveCategory(person.Categories.Last());

            session.SaveOrUpdate(person);
        }
开发者ID:ChrisMissal,项目名称:atxc,代码行数:11,代码来源:ShouldSavePersonWithCategoriesRemoved.cs

示例10: UpdateColumnDescription

        public static void UpdateColumnDescription(int columnId, string newDescription, ISession session)
        {
            var column = session.Query<ColumnEntity>().First(x => x.Id == columnId);
            column.Description = newDescription;

            using (var transaction = session.BeginTransaction())
            {
                session.SaveOrUpdate(column);
                transaction.Commit();
            }
        }
开发者ID:razed1,项目名称:DatabaseWiki,代码行数:11,代码来源:ColumnPersist.cs

示例11: UpdateTableDescription

        public static void UpdateTableDescription(int tableId, string newDescription, ISession session)
        {
            var table = session.Query<TableEntity>().First(x => x.Id == tableId);
            table.Description = newDescription;

            using(var transaction = session.BeginTransaction())
            {
                session.SaveOrUpdate(table);
                transaction.Commit();
            }
        }
开发者ID:razed1,项目名称:DatabaseWiki,代码行数:11,代码来源:TablePersist.cs

示例12: CreateFileCreateEventHandler

        private static void CreateFileCreateEventHandler(ISession session)
        {
            var workflow = new DefinedWorkflow();
            workflow.Name = "DeleteFileOnCreate";
            session.SaveOrUpdate(workflow);

            var definedTask = new DefinedTask();
            definedTask.Name = "Test";
            definedTask.RunCode =
                @"foreach(var parameter in parameters)
                                    {
                                        System.Console.WriteLine(""{0}:{1}:{2}"", parameter.Category, parameter.Name, parameter.Value);
                                    }

                                    string hostname = parameters.Where(p => p.Category == ""EventParameter"" && p.Name == ""Client"").Single().Value;
                                    string path = parameters.Where(p => p.Category == ""EventParameter"" && p.Name == ""Path"").Single().Value;
                                    string file = parameters.Where(p => p.Category == ""EventParameter"" && p.Name == ""Filename"").Single().Value;

                                    string filePath = System.IO.Path.Combine(path, file);

                                    System.Console.WriteLine(hostname);
                                    System.Console.WriteLine(filePath);

                                    File.Delete(hostname, filePath);

                                    return 0;";
            session.SaveOrUpdate(definedTask);

            var definedWorkflowStep = new DefinedWorkflowStep();
            definedWorkflowStep.DefinedTask = definedTask;
            definedWorkflowStep.DefinedWorkflow = workflow;
            session.SaveOrUpdate(definedWorkflowStep);

            var nextWorkflowStep = new DefinedNextWorkflowStep();
            nextWorkflowStep.DefinedWorkflow = workflow;
            nextWorkflowStep.NextStep = definedWorkflowStep;
            nextWorkflowStep.PreviousStep = null;
            session.SaveOrUpdate(nextWorkflowStep);

            var lastWorkflowStep = new DefinedNextWorkflowStep();
            lastWorkflowStep.DefinedWorkflow = workflow;
            lastWorkflowStep.PreviousStep = definedWorkflowStep;
            lastWorkflowStep.NextStep = null;
            session.SaveOrUpdate(lastWorkflowStep);

            var defaultEventHandler = new EventHandler();
            defaultEventHandler.DefinedWorkflow = workflow;
            defaultEventHandler.EventGroupTypes = "Filesystem";
            defaultEventHandler.EventType = "Add";

            session.SaveOrUpdate(defaultEventHandler);
        }
开发者ID:SabotageAndi,项目名称:jarvis,代码行数:52,代码来源:Program.cs

示例13: PerformAction

        public object PerformAction(Resource resource, ISession dataSession)
        {
            if (resource.Id == 0)
            {
                try
                {
                    resource.Tags = resource.Tags.WrapCommas();
                    dataSession.SaveOrUpdate(resource);
                    return GenerateResource(resource);
                }
                catch (Exception exception)
                {
                    return new { status = "failed", exception = exception.ToString() };
                }
            }

            return UpdateExistingResource(resource, dataSession);
        }
开发者ID:GiveCampUK,项目名称:CTTSearch,代码行数:18,代码来源:ResourceUpdateCommand.cs

示例14: ResetPassword

        public static void ResetPassword(ISession session, int id, string hash, string newPassword)
        {
            Login login = session.Load<Login>(id);

            if (login == null)
            {
                throw new Exception(string.Format("Invalid login id '{0}'.", id));
            }

            if (GetPasswordHash(login.Password) != hash)
            {
                throw new Exception(string.Format("Invalid hash code '{0}'.", hash));
            }

            login.Password = GetPasswordHash(newPassword);
            session.SaveOrUpdate(login);
            session.Flush();
        }
开发者ID:dblock,项目名称:dblog,代码行数:18,代码来源:ManagedLogin.cs

示例15: UpdateExistingResource

        private static object UpdateExistingResource(Resource resource, ISession dataSession)
        {
            using (var tx = dataSession.BeginTransaction())
            {

                var existing = dataSession.CreateCriteria<Resource>()
                    .Add(Restrictions.IdEq(resource.Id)).UniqueResult<Resource>();
                if (existing == null)
                {
                    return new { status = "failed", message = "Resource does not exist" };
                }
                existing.LongDescription = resource.LongDescription;
                existing.ResourceType = resource.ResourceType;
                existing.ShortDescription = resource.ShortDescription;
                existing.Title = resource.Title;
                existing.Uri = resource.Uri;
                existing.Tags = resource.Tags.WrapCommas();
                dataSession.SaveOrUpdate(existing);
                tx.Commit();
            }

            return GenerateResource(resource);
        }
开发者ID:GiveCampUK,项目名称:CTTSearch,代码行数:23,代码来源:ResourceUpdateCommand.cs


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