我尝试使用时遇到了很多问题Microsoft.SqlServer.Types.SqlGeography.我完全知道在Linq to Sql中对此的支持并不是很好.我尝试了很多方法,从预期的方式(数据库类型geography,CLR类型SqlGeography)开始.这产生了NotSupportedException,这通过博客广泛讨论.
然后我走了将geography列视为一个路径varbinary(max),就像geography存储为二进制的UDT一样.这似乎工作正常(使用一些二进制读取和写入扩展方法).
但是,我现在遇到了一个相当模糊的问题,这似乎并没有发生在许多其他人身上.
System.InvalidCastException:无法将类型为"Microsoft.SqlServer.Types.SqlGeography"的对象强制转换为"System.Byte []".
ObjectMaterializer在迭代查询时抛出此错误.它似乎只有在包含地理列的表隐式包含在查询中时(即使用EntityRef<>属性进行连接)才会出现.
System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()
我的问题:如果我正在检索geography列varbinary(max),我可能会发现反向错误:无法转换byte[]为SqlGeography.我明白了.我没有.我对部分LINQ to SQL类有一些隐藏二进制转换的特性......那可能是问题吗?
任何帮助表示赞赏,我知道可能没有足够的信息.
附加功能:
geography在Visual Studio DBML"服务器数据类型" =设计师列geography生成此错误:The specified type 'geography' is not a valid provider type.geography在Visual Studio DBML没有"服务器数据类型"列设计师生成此错误:Could not format node 'Value' for execution as SQL.首先,抱歉,这太久了.我可能不需要所有代码,但我想确定.
其次,我的实际问题是,我做错了什么,或者这是joda-time库中的错误?
我正在尝试使用joda-time(1.6.1)来计算,然后格式化持续时间.
我目前正在使用Period,这可能是错误的选择.如果是的话请告诉我.但是,即使这是错误的选择,我也很确定这不应该发生.
我正在初始化一个Period使用毫秒(通过将持续时间(以秒为单位)乘以1000).我正在使用,Period所以我可以格式化并打印它:
long durationLong = durationSec * 1000;
Period duration = new Period(durationLong);
PeriodFormatter daysHoursMinutes = new PeriodFormatterBuilder()
.appendHours()
.appendSeparator(":")
.appendMinutes()
.appendSeparator(":")
.appendSeconds()
.toFormatter();
String formattedString = daysHoursMinutes.print(callDuration.normalizedStandard());
Run Code Online (Sandbox Code Playgroud)
我在下面得到了Exception,并查看了源代码以确认循环.
Caused by: java.lang.StackOverflowError
at java.util.Hashtable.get(Hashtable.java:274)
at java.util.Properties.getProperty(Properties.java:177)
at java.lang.System.getProperty(System.java:440)
at java.lang.System.getProperty(System.java:412)
at org.joda.time.DateTimeZone.getDefault(DateTimeZone.java:132)
at org.joda.time.DateTimeZone.forID(DateTimeZone.java:190)
at org.joda.time.DateTimeZone.getDefault(DateTimeZone.java:132)
at org.joda.time.DateTimeZone.forID(DateTimeZone.java:190)
...snip (all the same)...
at org.joda.time.DateTimeZone.getDefault(DateTimeZone.java:132)
at org.joda.time.DateTimeZone.forID(DateTimeZone.java:190)
at org.joda.time.DateTimeZone.getDefault(DateTimeZone.java:132)
at org.joda.time.DateTimeZone.forID(Dat
Run Code Online (Sandbox Code Playgroud)
周期(长):
public Period(long duration) {
super(duration, null, null);
}
Run Code Online (Sandbox Code Playgroud)
super(long,PeriodType,Chronology):
protected …Run Code Online (Sandbox Code Playgroud)