Nhibernate - Dialect does not support DbType.Double
2013-01-28 15:19
423 查看
引用的文件:
Fluent Nhibernate 1.3.0
Nhibernate 3.3.1
.NET Framework 4.0
MySQL 5.0
在统计模块里需要用到sum这个函数,这里有一个测试方法来统计某一条件的总价(美元),TotalCostUsd是一个double?类型,
测试结果报出来这个错误:
第一反应是MySQL不支持double类型?这不可能啊...LINQ不支持double类型?这也不可能啊...
Dialect?
http://www.blogjava.net/Alpha/archive/2008/04/15/193094.html https://community.jboss.org/wiki/DatabasesSupportedByNHibernate?_sscc=t
我把配置修改为:
增加
Run Tests.....
It works!
Fluent Nhibernate 1.3.0
Nhibernate 3.3.1
.NET Framework 4.0
MySQL 5.0
在统计模块里需要用到sum这个函数,这里有一个测试方法来统计某一条件的总价(美元),TotalCostUsd是一个double?类型,
[TestMethod] public void TestMethod1() { NHibernateHelper helper = new NHibernateHelper(_connectionString); UnitOfWork unitOfWork = new UnitOfWork(helper.SessionFactory); IRepository<Order> repository = new GenericRepository<Order>(unitOfWork.Session); var list = repository.FilterBy(o => o.Factory.Code.Equals("A8") && o.State == OrderState.ConfirmShipping); var total = list.Sum(o => o.TotalCostUsd) ?? 0D; Assert.AreEqual(100, total); }
测试结果报出来这个错误:
Dialect does not support DbType.Double
第一反应是MySQL不支持double类型?这不可能啊...LINQ不支持double类型?这也不可能啊...
Dialect?
http://www.blogjava.net/Alpha/archive/2008/04/15/193094.html https://community.jboss.org/wiki/DatabasesSupportedByNHibernate?_sscc=t
我把配置修改为:
private ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database(MySQLConfiguration.Standard.Dialect<MySQL5Dialect>().ConnectionString(_connectionString)) .Mappings(m => m.FluentMappings.AddFromAssembly(typeof(PekingHandicraftPMS.Data.NHibernateMapping.UserMap).Assembly) ) //.ExposeConfiguration(CreateSchema) .BuildSessionFactory(); }
增加
Dialect<MySQL5Dialect>()
Run Tests.....
It works!
相关文章推荐
- dialect does not support sequences
- Dialect does not support identity key generation
- Dialect does not support identity key generation
- Dialect does not support sequences
- Dialect does not support identity key generation
- 数据库报错:OracleDialect does not support identity key generation
- <ERROR>JpaDialect does not support savepoints - check your JPA provider's capabilities
- Dialect does not support sequences
- 【bug】org.hibernate.dialect.OracleDialect does not support identity key generation
- Dialect does not support identity key generation
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 解决方法
- MYSQL出现" Client does not support authentication "的解决方法
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- "Printer does not support A4 pap…
- 用root用户登陆PHPmyAdmin出现Client does not support authentication ...
- WebClient does not support concurrent I/O operations 错误的解决办法
- 虚拟机启动提示Your CPU does not support long mode. Use a 32bit distribution
- TypeError: 'dict_keys' object does not support indexing
- service httpd does not support chkconfig