【发布时间】:2013-11-22 21:03:35
【问题描述】:
我正在减少通过查询通过线路传输的字节数,在我写作时...我意识到我应该能够将接口传递给 QueryOver 对象并获取该接口属性的指定列。
是否可以将接口传递给 QueryOver 对象的选择或类似命令?它会只返回“映射”到界面的列吗?
例子:
Repository
.QueryOver<MyTable>()
.Select(table => table as IJustWantTheseColumnsInterface)
.Execute(Parameters);
//or
Repository
.QueryOver<MyTable>()
.Select<IJustWantTheseColumnsInterface>()
.Execute(Parameters);
//...
public class Table : IJustWantTheseColumnsInterface
{
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public Address Address { get; set; }
public Phone Phone { get; set; }
public DateTime BirthDate { get; set; }
public Occupation Occupation { get; set; }
public Employer Employer { get; set; }
//etc...
}
public interface IJustWantTheseColumnsInterface
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Phone Phone { get; set; }
}
【问题讨论】:
标签: c# nhibernate dto modularity