This is just a guess, but is it possible that SQL profiler may not
print the full value? Have you checked the actual stored value?

/Oskar



2009/9/26 Graham Bunce <[email protected]>:
>
> All,
>
> I raised a bug (NH-1973) which someone kindly pointed out was a
> limitation in SQL Server. My mapping file was mapping a .NET datetime
> to a NH Timestamp field and millisecond precision was being lost.
>
> After the update to the bug, I changed my test to the following
> mapping instead:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> assembly="NHibernate.Test"
>                   namespace="NHibernate.Test.NHSpecificTest.NH1973"
> default-access="field.camelcase"
>                   default-lazy="false">
>  <class name="DomainClass">
>    <id name="Id">
>      <generator class="assigned" />
>    </id>
>    <property name="Timestamp" type="datetime2" />
>  </class>
> </hibernate-mapping>
>
> This correctly creates the column as a DateTime2(7) in SQL Server
> 2008.
>
> Via SQL I can insert this value correctly into the table e.g. insert
> into DomainClass ([Id],[Timestamp])Values(10,'2009-09-23
> 16:28:21.489')
>
> and the millisecond is correctly saved.
>
> However through NH this c#
>
>            using (ISession session = this.OpenSession())
>            {
>                DomainClass entity = new DomainClass();
>                entity.Id = 1;
>        entity.Timestamp = DateTime.Parse("2009-09-23 16:28:21.489");
>                session.Save(entity);
>                session.Flush();
>            }
>
> results in this SQL being sent to the database
>
> exec sp_executesql N'INSERT INTO DomainClass (Timestamp, Id) VALUES
> (@p0, @p1)',N'@p0 datetime2(7),@p1 int',@p0='2009-09-23
> 16:28:21',@p1=1
>
> i.e. the millisecond precision has totally gone.
>
> I can't believe this is a bug... must be something I've got wrong in
> the mapping, but I can't see what. Can anybody help or is this a bug?
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to