gpt4 book ai didi

c# - 如何编写 Nhibernate 查询

转载 作者:行者123 更新时间:2023-11-30 13:19:27 25 4
gpt4 key购买 nike

<分区>

我有两个映射到数据库中的类。这些表通过字段“DeptId”彼此具有主键和外键关系。

Employee.cs

 public class Employee: Entity
{
public virtual Int32 Id { get; set; }
public virtual string Name { get; set; }
public virtual string Gender { get; set; }
public virtual Int32 Age { get; set; }
public virtual string Designation { get; set; }
public virtual bool Enabled { get; set; }
public virtual int CreatedById { get; set; }
public virtual DateTime CreatedDate { get; set; }
public virtual int? LastModifiedById { get; set; }
public virtual DateTime? LastModifiedDate { get; set; }
public virtual bool IsDeleted { get; set; }
public virtual Department Department { get; set; }
}

Department.cs

public class Department
{
public virtual int DeptId { get; set; }
public virtual string DeptName { get; set; }
public virtual bool Enabled { get; set; }
}

由于我是 NHibernate 的新手,我无法使用 QueryOver 编写更复杂的 Linq 查询。我已经编写了以下查询,但如何编写更高级的查询。请为此提供示例查询和引用。

var query = Session.QueryOver<Employee>().List(); 

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com