海阔天空

导航

06 2013 档案

NHibernate-NativeSQL
摘要:一、调用方式1、创建查询var sql = session.CreateSQLQuery("SELECT * FROM sns_User WHERE UserName LIKE :username");// 根据传入的SQL语句,获得一个ISQLQuery对象,进行查询操作。sql中包含一个命名参数:"username",NHibernate中使用“:”来表示参数开头,根据数据库类型自动转换为“@”。参数名可以是数字,如:“:0”,“:1”等。2、设置实体类3、设置参数4、结果转换返回指定列返回ORM实体类返回非ORM实体类 二、查询1、普通查询2、关联 阅读全文

posted @ 2013-06-27 22:51 达芬奇

NHibernate注意事项
摘要:1、检查映射文件是否正确2、检查配置文件的“嵌入的资源”选项3、检查Configuration是否加载了程序集 阅读全文

posted @ 2013-06-27 22:37 达芬奇

Request.IsAuthenticated
摘要:Original questionthat the answer below refers to:I have a forms based application that is giving me fits. I noticed that, in a location where the IsAuthenticated property had been True, it was now false and the was not working as expected. I am wondering if I have a setting that is invalid??Can anyo 阅读全文

posted @ 2013-06-25 18:46 达芬奇

NHibernate-查询
摘要:NHibernate Linq从NHibernate 3.x开始,将很多类库集成到了NHibernate.dll中。3.0中需要的类库:NHibernateIesi.CollectionsRemotion.Data.LinqNHibernate.ByteCode.CastleCastle.CoreAntlr.Runtime3.1中集成了Remotion.Data.LinqNHibernateIesi.CollectionsNHibernate.ByteCode.CastleCastle.Core到了3.2只需要两个类库:NHibernateIesi.Collections对应的Fluent N 阅读全文

posted @ 2013-06-11 22:53 达芬奇

Hibernate-配置文件
摘要:var configuration = new NH.Cfg.Configuration();configuration.Configure(cfgPath);Configuration对象创建后,需要调用Configure()方法来加载配置文件,hibernate默认在app.config和web.config中查找配置,也可以指定配置文件的位置,通常设置为程序输出目录(bin)下“hibernate.cfg.xml”文件。程序方式配置var configuration = new NH.Cfg.Configuration();configuration.SetProperty(" 阅读全文

posted @ 2013-06-07 23:49 达芬奇

Hibernate学习-映射文件
摘要:1、XML申明namespace和assembly为必填,否则会提示找不到映射文件mapping在新版本中设置为2.22、使用tinyint等来存储bool类型以前的版本需要实现一个IUserType类,3.x版本后已经不需要了,可以直接在映射中直接设置为tinyint。3、属性关联数据字典但不做数据更新public virtual Area Area { get; set; } // 实体类属性,不进行数据更新这样配置可以在读取的时候自动关联地区,但是这个属性不参与数据库存储操作 阅读全文

posted @ 2013-06-07 22:00 达芬奇