Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.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# 在Sqlite3中存储System.Uri_C#_.net_Sqlite_Sqlite Net - Fatal编程技术网

C# 在Sqlite3中存储System.Uri

C# 在Sqlite3中存储System.Uri,c#,.net,sqlite,sqlite-net,C#,.net,Sqlite,Sqlite Net,我决定在.NET应用程序中使用SQLite3,并且在实体中定义了一些System.Uri属性。 我正在尝试使用,正在做: 但我得到的只是一个:System.NotSupportedException:“不知道System.Uri” 有没有办法继续使用System.Uri并将其保存为字符串 非常感谢这取决于您对URI的需求,假设您想要绝对URI: string uristring = uri_variable.AbsoluteUri; 您还可以检索用于构造uri的原始字符串: string ur

我决定在.NET应用程序中使用SQLite3,并且在实体中定义了一些System.Uri属性。 我正在尝试使用,正在做:

但我得到的只是一个:System.NotSupportedException:“不知道System.Uri”

有没有办法继续使用System.Uri并将其保存为字符串


非常感谢

这取决于您对URI的需求,假设您想要绝对URI:

string uristring = uri_variable.AbsoluteUri;
您还可以检索用于构造uri的原始字符串:

string uristring = uri_variable.OriginalString;
这样,您仍然使用URI,但将其作为字符串保存在SQLite中

编辑:

库抛出Sqlite.cs的一个异常行2080,因为没有考虑System.Uri类型。
我认为可以将其添加到列表中,然后作为示例翻译为varchar100。当然,这没有经过测试,我相信将其保存为字符串应该是一种方法。

这里的问题是,SQLite数据类型不包括本机的Uri,因此我想知道是否有某种映射功能,如属性或映射方法,让SQLite/-net知道如何序列化和反序列化System.Uri对象,以及要使用哪种类型的关联。它在conn.CreateTable中崩溃了吗?是的:正如我所写的,它会引发System.NotSupportedException,表示不了解System.Uria。在2080上,您可以看到它在哪里抛出异常。您可以播放并放置另一个案例,如:else if clrType==typeofSystem.Uri{return varchar100;examplewo,编写SQLite net的人显然不知道类型在SQLite中是如何工作的。。。
string uristring = uri_variable.OriginalString;