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


C# ISession.Get方法代码示例

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


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

示例1: Refresh

 public static void Refresh(this Patient patient, PatientDto from, ISession session)
 {
     if (from.Tag != null) { patient.Tag = session.Get<Tag>(from.Tag.Id) ?? patient.Tag; }
     if (from.Insurance != null) { patient.Insurance = session.Get<Insurance>(from.Insurance.Id) ?? patient.Insurance; }
     if (from.Practice != null) { patient.Practice = session.Get<Practice>(from.Practice.Id) ?? patient.Practice; }
     if (from.Profession != null) { patient.Profession = session.Get<Profession>(from.Profession.Id) ?? patient.Profession; }
     if (from.Reputation != null) { patient.Reputation = session.Get<Reputation>(from.Reputation.Id) ?? patient.Reputation; }
 }
开发者ID:seniorOtaka,项目名称:ndoctor,代码行数:8,代码来源:EntityRefreshExtension.cs

示例2: ChangeTheRole

 private static void ChangeTheRole(ISession session)
 {
     var parent = session.Get<User>(1);
     Print(parent.ToString());
     var role = session.Get<Role>(3);
     Print(role.ToString());
     parent.Role = role;
     Print(parent.ToString());
     session.Flush();
 }
开发者ID:minhajuddin,项目名称:playground,代码行数:10,代码来源:Program.cs

示例3: GetObject

        public static async Task<Employeejob> GetObject(ISession se, Employee e, FormCollection fc)
        {
            string paramJoindate = GetParam("join_date", fc);
            DateTime joindate = CommonHelper.GetDateTime(paramJoindate);

            string paramConfirmdate = GetParam("confirm_date", fc);
            DateTime confirmdate = CommonHelper.GetDateTime(paramConfirmdate);

            string paramDesignationid = GetParam("designation_id", fc);
            Designation des = string.IsNullOrEmpty(paramDesignationid) || paramDesignationid == "0" ? null : new Designation();

            string paramDepartmentid = GetParam("department_id", fc);
            Department dept = string.IsNullOrEmpty(paramDepartmentid) || paramDepartmentid == "0" ? null : new Department();

            string paramEmploymentstatusid = GetParam("employment_status_id", fc);
            Employmentstatus es = string.IsNullOrEmpty(paramEmploymentstatusid) || paramEmploymentstatusid == "0" ? null : new Employmentstatus();

            string paramJobcategoryid = GetParam("job_category_id", fc);
            Jobcategory jobcat = string.IsNullOrEmpty(paramJobcategoryid) || paramJobcategoryid == "0" ? null : new Jobcategory();

            if (des != null)
                des = await Task.Run(() => { return se.Get<Designation>(CommonHelper.GetValue<int>(paramDesignationid)); });

            if (dept != null)
                dept = await Task.Run(() => { return se.Get<Department>(CommonHelper.GetValue<int>(paramDepartmentid)); });

            if (es != null)
                es = await Task.Run(() => { return se.Get<Employmentstatus>(CommonHelper.GetValue<int>(paramEmploymentstatusid)); });

            if (jobcat != null)
                jobcat = await Task.Run(() => { return se.Get<Jobcategory>(CommonHelper.GetValue<int>(paramJobcategoryid)); });

            Employeejob o = e.Employeejob;

            if (o == null)
            {
                o = new Employeejob();
                o.Id = e.Id;
            }

            o.Designation = des;
            o.Department = dept;
            o.Employmentstatus = es;
            o.Jobcategory = jobcat;
            o.Joindate = joindate;
            o.Confirmdate = confirmdate;

            return o;
        }
开发者ID:kenny007,项目名称:Payroll_MVC4,代码行数:49,代码来源:EmployeejobHelper.cs

示例4: 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

示例5: Root

        internal static Section Root(ISession session) 
        {
            //Section root = session.Get<Section>(Section.RootUri);
            //root.Name = session.Config.RootTitle;

            Section root = session.Get<Section>(Section.FeaturedUri);
            root.Name = "Featured";

            return root;
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:10,代码来源:Section.cs

示例6: 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

示例7: ConfigViewModel

        public ConfigViewModel(ISession session, IEventAggregator eventAggregator)
        {
            _session = session;
            _eventAggregator = eventAggregator;

            CombatantsCount = 3;
            ActiveValue = ConfigValue.CombatantsCount;
            SetupNewMode();

            _allCombatants = _session.Get<List<Uri>>(Session.CombatantImages);
        }
开发者ID:PapaMufflon,项目名称:CodingDojoHelper,代码行数:11,代码来源:ConfigViewModel.cs

示例8: init

        public void init()
        {
            cfg = new Configuration();
            cfg.Configure();
            cfg.AddAssembly(typeof(Empresa).Assembly);
            //new SchemaExport(cfg).Execute(true, true, false); // Crearía las tablas.
            fab_sesion = cfg.BuildSessionFactory();
            sesion = fab_sesion.OpenSession();

            //miEmp = sesion.CreateQuery("from Empresa WHERE Id=5 Select Empresa").List<Empresa>().First(); //LINQ
            //no está bueno esto, sería ideal buscar un id existente
            miEmp = sesion.Get<Empresa>(1);
        }
开发者ID:perHub,项目名称:MetGrupoI,代码行数:13,代码来源:NHibernateTestEliminarEmpresa.cs

示例9: Can_insert_a_tag

        public void Can_insert_a_tag()
        {
            using (session = NHibernateConfig.SessionFactory.OpenSession())
            {
                InsertTag(description: "This is a test");
            }

            using (session = NHibernateConfig.SessionFactory.OpenSession())
            {
                tag = session.Get<Tag>(tagId);
                tag.Description.Should().Be("This is a test");
            }
        }
开发者ID:jarrettmeyer,项目名称:portfolio-mvc,代码行数:13,代码来源:TagMapTests.cs

示例10: GetWidgetData

		public object GetWidgetData(Widget widget, WidgetParameter[] parameters, ISession session, Logger logger)
		{
			var sensorId = parameters.First(p => p.Name == PARAM_SENSOR_ID).ValueGuid;
			var sensor = session.Get<TemperatureSensor>(sensorId);

			return new
			{
				id = sensorId, 
				timestamp = sensor.Timestamp,
				t = sensor.CurrentTemperature,
				h = sensor.CurrentHumidity,
				showHumidity = sensor.ShowHumidity
			};
		}
开发者ID:3660628,项目名称:thinking-home,代码行数:14,代码来源:MicroclimateWidgetDefinition.cs

示例11: GetClient

        /// <summary>
        /// Get a client from a servic stack session otherwise new up
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        public static JsonServiceClient GetClient(ISession session)
        {
            try
            {
                var client = session.Get<JsonServiceClient>("Client");
                if (client != null)
                {
                    return client;
                }

                client = new JsonServiceClient(GlobalHelper.GetServiceUrl());
                session.Set("Client", client);
                return client;
            }
            catch (Exception)
            {
                return new JsonServiceClient(GlobalHelper.GetServiceUrl());
            }
        }
开发者ID:peter-dangelo,项目名称:ServiceStackMVC,代码行数:24,代码来源:GlobalHelper.cs

示例12: ChangeTextSetting

        public void ChangeTextSetting(string key, string value, ISession session)
        {
            if (Configuration.TribalWarsConfiguration.StringConfiguration.ContainsKey(key))
            {
                StringConfiguration config = Configuration.TribalWarsConfiguration.StringConfiguration[key];

                StringConfiguration config1 = session.Get<StringConfiguration>(key);
                config1.Value = value;
                config.Value = value;
                session.Update(config1);
            }
            else
            {
                StringConfiguration config = new StringConfiguration();
                config.Key = key;
                config.Value = value;
                Configuration.TribalWarsConfiguration.StringConfiguration.Add(key, config);
                session.Save(config);
            }
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:20,代码来源:AdminConfigurationMethods.cs

示例13: ChangeNumericSetting

        public void ChangeNumericSetting(string key, double value, ISession session)
        {
            if (Configuration.TribalWarsConfiguration.NumericConfiguration.ContainsKey(key))
            {
                NumericConfiguration config = Configuration.TribalWarsConfiguration.NumericConfiguration[key];
                config.Value = value;

                NumericConfiguration config1 = session.Get<NumericConfiguration>(key);
                config1.Value = value;
                session.Update(config1);
                session.Flush();
            }
            else
            {
                NumericConfiguration config = new NumericConfiguration();
                config.Key = key;
                config.Value = value;
                Configuration.TribalWarsConfiguration.NumericConfiguration.Add(key, config);
                session.Save(config);
                session.Flush();
            }
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:22,代码来源:AdminConfigurationMethods.cs

示例14: FinishLock

 public void FinishLock(ISession session)
 {
     var dbLock = session.Get<DbLock>(DbLock.Id);
     session.Delete(dbLock);
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:5,代码来源:TaskItem.cs

示例15: ValidarId

 private static void ValidarId(Indicador indicador, ISession session)
 {
     if (session.Get<Indicador>(indicador.Id) != null)
         throw new BLLException("Esse id já está sendo usado por outro indicador");
 }
开发者ID:GabrielMCardozo,项目名称:Sind,代码行数:5,代码来源:ManterIndicador.cs


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