google-code-export / dataobjectsdotnet

Automatically exported from code.google.com/p/dataobjectsdotnet
0 stars 0 forks source link

TimeSpan to bigint conversion truncates nanoseconds #818

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Model:

    [Serializable]
    [HierarchyRoot]
    public class MyEntity : Entity
    {
        [Field, Key]
        public int Id { get; private set; }

        [Field(Length = 100)]
        public string Text { get; set; }

        [Field]
        public TimeSpan TS { get; set; }
    }

Program:

            var config = DomainConfiguration.Load("Default");
            var domain = Domain.Build(config);

            long ticks = 301092093;

            using (Session.Open(domain))
            {
                using (var transactionScope = Transaction.Open())
                {
                    TimeSpan now = new TimeSpan(ticks);

                    // Creating new persistent object
                    var helloWorld = new MyEntity
                    {
                        Text = "Hello World!", TS = now
                    };
                    // Committing transaction
                    transactionScope.Complete();
                }
            }

            // Reading all persisted objects from another Session
            using (Session.Open(domain))
            {
                using (var transactionScope = Transaction.Open())
                {
                    foreach (var myEntity in Query.All<MyEntity>())
                    {
                        Debug.Assert(myEntity.TS.Ticks == ticks); <= FAILS HERE
                        Console.WriteLine(myEntity.Text);
                    }
                    transactionScope.Complete();
                }
            }

Original issue reported on code.google.com by Dmitri.Maximov on 21 Sep 2010 at 11:51

GoogleCodeExporter commented 9 years ago

Original comment by Dmitri.Maximov on 14 Oct 2010 at 2:47

GoogleCodeExporter commented 9 years ago

Original comment by Dmitri.Maximov on 20 Oct 2010 at 12:57