本文整理汇总了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; }
}
示例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();
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
}
示例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
};
}
示例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());
}
}
示例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);
}
}
示例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();
}
}
示例14: FinishLock
public void FinishLock(ISession session)
{
var dbLock = session.Get<DbLock>(DbLock.Id);
session.Delete(dbLock);
}
示例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");
}