KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm working first time with FluentNHibernate , trying to map classes to SQL Express database. In general it works, but I'm unable to map Double or Decimal property types to specific scale/precision . Below shows result for a single property that I tested over and over with SchemaUpdate.Execute . In no case was I able to get it to work. Would be really helpful to hear some explanation to the mappings that does not work as I expect (2-8)? // Ok mappings: 1) Decimal : Map(Function(x) x.Balance) >> Decimal(19, 5) // Mappings "errors": 2) Double : Map(Function(x) x.Balance).CustomSqlType("decimal") >> Decimal(18,0) - Why 0 precision is the default mapping here? 3) Double : Map(Function(x) x.Balance) >> Float , But; when running SchemaValidator after: HibernateException : Wrong column type in FnhDb.dbo.Account for column Balance. Found: float, Expected DOUBLE PRECISION 4) Decimal : Map(Function(x) x.Balance).Scale(9).Precision(2) >> SqlException : The scale (9) for column 'Balance' must be within the range 0 to 2. 5,6) Decimal or Double : Map(Function(x) x.Balance).Scale(9).Precision(2).CustomSqlType("numeric") >> numeric(18,0) 7,8) Decimal or Double : Map(Function(x) x.Balance).Scale(9).Precision(2).CustomSqlType("decimal") >> Decimal(18,0) EDIT: I include code and hbm.xml (export) for case (4) here: Public Class AccountMap Inherits ClassMap(Of Account) Public Sub New() MyBase.New() Id(Function(x) x.Id).GeneratedBy.Identity() Map(Functi
Tags (comma-separated)
Save Edits
Cancel