Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PostgreSQL不';不保存完整的日期时间偏移量_C#_Entity Framework_Postgresql_Devart - Fatal编程技术网

C# PostgreSQL不';不保存完整的日期时间偏移量

C# PostgreSQL不';不保存完整的日期时间偏移量,c#,entity-framework,postgresql,devart,C#,Entity Framework,Postgresql,Devart,我在PostgreSQL或Devart数据库连接库中遇到了一个错误。以下是我创建的一个简单测试应用程序: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DateTimeOffsetTest { class Program { static void Main(

我在PostgreSQL或Devart数据库连接库中遇到了一个错误。以下是我创建的一个简单测试应用程序:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DateTimeOffsetTest
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var context = new Context())
            {
                var e = new Ent() { CreatedOn = DateTimeOffset.Now };
                Console.WriteLine(e.CreatedOn.UtcDateTime.Ticks);
                context.Ents.Add(e);
                context.SaveChanges();
            }

            using (var context = new Context())
            {
                var ent = context.Ents.Single();

                Console.WriteLine(ent.CreatedOn.UtcDateTime.Ticks);
                Console.Read();

                context.Ents.Remove(ent);
                context.SaveChanges();
            }
        }
    }
}
我希望写入控制台的两行是相同的,但是第二行的最后一位总是有一个0。例如:


PostgreSQL的设置方式是否存在精度问题?如果是,我是否可以以某种方式进行更改?如果我使用SqlServer作为数据库,则此测试可以正常工作。

如果CreatedOn是PostgreSQL时间戳,则精度为1微秒。1分是0.1微秒。

我明白了,有没有办法提高时间戳的精度?我想你可以把蜱虫储存起来。64位整数(bigint)对于时间戳来说已经足够了。如果您不喜欢在程序中使用记号,您可以将记号存储为支持字段,然后使用DateTime not mapped字段好主意,我可能不得不这样做。谢谢你的帮助