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

推荐订阅源

博客园 - 【当耐特】
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
Schneier on Security
Schneier on Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Last Watchdog
The Last Watchdog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News and Events Feed by Topic
P
Proofpoint News Feed
H
Heimdal Security Blog
云风的 BLOG
云风的 BLOG
H
Hacker News: Front Page
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
F
Full Disclosure
小众软件
小众软件
Martin Fowler
Martin Fowler
Security Latest
Security Latest
The Cloudflare Blog
Hacker News: Ask HN
Hacker News: Ask HN
C
Check Point Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
I
InfoQ
AI
AI
Blog — PlanetScale
Blog — PlanetScale
I
Intezer
H
Hackread – Cybersecurity News, Data Breaches, AI and More
M
MIT News - Artificial intelligence
V
Vulnerabilities – Threatpost
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
V2EX
N
News and Events Feed by Topic
C
Cybersecurity and Infrastructure Security Agency CISA
T
Troy Hunt's Blog
大猫的无限游戏
大猫的无限游戏
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Register - Security
The Register - Security
Forbes - Security
Forbes - Security
Recent Announcements
Recent Announcements
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cisco Talos Blog
Cisco Talos Blog
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
S
SegmentFault 最新的问题
S
Securelist
Cloudbric
Cloudbric
T
Tenable Blog
D
Docker

博客园 - 不搽雪花膏

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();

}