惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
小众软件
小众软件
月光博客
月光博客
D
DataBreaches.Net
L
LangChain Blog
美团技术团队
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
博客园 - 司徒正美
aimingoo的专栏
aimingoo的专栏
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Help Net Security
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog
I
InfoQ
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
博客园 - 三生石上(FineUI控件)
腾讯CDC
Martin Fowler
Martin Fowler

博客园 - 不搽雪花膏

linux网关设置 <!DOCTYPE>标签与table高度100% (转) linux运行apache出现403错误 Ubuntu 12.10 Tty (字符终端) 显示中文,和字体大小设置 64位系统下组件服务的查看 转 Web前端性能优化全攻略 Castle ActiveRecord 笔记 - 不搽雪花膏 WQL测试工具 [转载]HttpModule与HttpHandler详解 转载 云计算七问七答 [转]整理.net程序集加载方法 MySQL(5.0)导出导入 .NET代码编写规范 Hibernate配置参数 [转]PKCS 证书 细数.net3.0的各项新特性 Jquery示例 Jquery入门 [转]Response.End、Response.Redirect 或 Server.Transfer 方法与 ThreadAbortException 异常
ActiveRecord返回部分字段的查询
不搽雪花膏 · 2011-12-13 · via 博客园 - 不搽雪花膏

1. 自定义非受管实体类

namespace IOT{

  public class CustomerProjection{

    public int ID = 0;

    public string Name = "";
    public CustomerProjection(int id, string name){

      ID = id;

      Name = name;
    }

  }

}

2. 在实体类属性添加对自定义非受管实体类的引入

[Imprt(typeof(IOT.CustomerProjection), "CustomerProjection")]

[ActiveRecord("Customers")]

public class Customer : ActiveRecordBase<Customer>

{

[PrimaryKey(PrimaryKeyType.Assigned)]

public string CustomerID

{

get { return customerID; }

set { customerID = value; }

}

.....

}

3. 在代码中用检索字段生成自定义非受管实体类

protected void Page Load(object sender, EventArgs e)

{

IActiveRecordQuery query = new HqlBasedQuery(typeof (Customer),

@"select new CustomerProjection(c.CustomerID, c.CompanyName)

from Customer c join c.Orders o where c.Country = 'USA'

group by c.CustomerID, c.CompanyName, c.City, c.Region

");

GridView1.DataSource = ActiveRecordMediator.ExecuteQuery(query);

GridView1.DataBind();

}