Castle 中ActiveRecord查询部分字段属性的投影(Projections)使用教程
来源:互联网 发布:lumia 813刷linux 编辑:程序博客网 时间:2024/05/17 05:05
Castle 中ActiveRecord查询部分字段属性的投影(Projections)使用教程
很多 Castle ActiveRecord系列教程都没有介绍投影(Projections)的使用,这里我用代码举例下....
查询部分字段属性..很方便灵活...同时效率也提高很不少..特别是大表多字段的情况下...(问题咨询QQ1163551688)
[Test]
public void ScalarProjectionQueryTest()
{
Blog blog = new Blog();
blog.Name = "hammett's blog";
blog.Author = "hamilton verissimo";
blog.Save();
ScalarProjectionQuery<Blog, int> proj = new ScalarProjectionQuery<Blog, int>(Projections.RowCount());
int rowCount = proj.Execute();
Assert.AreEqual(1, rowCount);.(问题咨询QQ1163551688)
}
[Test]
public void UnTypedProjectionQueryTest()
{
Blog blog = new Blog();
blog.Name = "hammett's blog";
blog.Author = "hamilton verissimo";
blog.Save();
ProjectionQuery<Blog> proj = new ProjectionQuery<Blog>(
Projections.ProjectionList()
.Add(Projections.Property("Name"))
.Add(Projections.Property("Author")));
IList<object[]> results = proj.Execute();
Assert.AreEqual(blog.Name, results[0][0]);
Assert.AreEqual(blog.Author, results[0][1]);.(问题咨询QQ1163551688)
}
[Test]
public void TypedProjectionQueryTest()
{
Blog blog = new Blog();
blog.Name = "hammett's blog";
blog.Author = "hamilton verissimo";
blog.Save();
ProjectionQuery<Blog, KeyValuePair<string, string>> proj = new ProjectionQuery<Blog, KeyValuePair<string, string>>(
Projections.ProjectionList()
.Add(Projections.Property("Name"))
.Add(Projections.Property("Author")));
IList<KeyValuePair<string, string>> results = proj.Execute();
Assert.AreEqual(blog.Name, results[0].Key);
Assert.AreEqual(blog.Author, results[0].Value);.(问题咨询QQ1163551688)
}
- Castle 中ActiveRecord查询部分字段属性的投影(Projections)使用教程
- Castle ActiveRecord中CountQuery的使用
- Castle ActiveRecord的排序查询
- Castle ActiveRecord 的分页查询
- 在Castle ActiveRecord中使用NHibernate
- Castle ActiveRecord 中使用Access数据库
- 使用CASTLE.ActiveRecord的注意事项之一:总览
- 使用Castle.ActiveRecord的注意事项三:继承
- 使用Castle.ActiveRecord的注意事项之一:总览
- WPF使用Castle.ActiveRecord的简单示例
- 使用Castle.ActiveRecord框架的一些问题
- Castle ActiveRecord使用笔记
- Castle ActiveRecord学习实践(7):使用HQL查询
- NHibernate之 Castle.ActiveRecord中使用分页控件AspNetPager
- 使用 Castle ActiveRecord 开发发现的一些问题
- 使用Castle.ActiveRecord的注意事项之二:级联
- 使用Castle.ActiveRecord的注意事项之三:继承
- Castle学习系列(六)---ActiveRecord属性校验
- pb 转到excel表格如何在表格的最上方加上说明文字
- 插入特殊符号的两种方法
- SQL Server 安装和运行问题
- wingsl在visual studio 2008下应用
- C# 日期函数使用技巧汇总
- Castle 中ActiveRecord查询部分字段属性的投影(Projections)使用教程
- IE中打开服务器下的MHT文件
- java读取word-excel-ppt文件
- 更改外购入库单的不一致辞价格
- 缺点
- ACE的MFC库的编译
- Linux Windows MySQL 更改MySQL数据库目录的位置
- mysql left join,right join,inner join用法举例
- 众核技术报告会归来