Subsonic DateTime字段更新导致异常
过去几天我一直在使用亚音速3.0,但遇到了一个问题。使用ActiveRecord并对现有记录调用save会导致:Subsonic DateTime字段更新导致异常,subsonic,subsonic3,Subsonic,Subsonic3,过去几天我一直在使用亚音速3.0,但遇到了一个问题。使用ActiveRecord并对现有记录调用save会导致: [SqlException (0x80131904): The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The st
[SqlException (0x80131904): The conversion of a char data type to a datetime
data type resulted in an out-of-range datetime value.
The statement has been terminated.]
我使用的代码只是为了演示问题:
public void ButtonCreate_OnClick(object sender, EventArgs e) {
stPost post = new stPost();
post.postCreatedDate = DateTime.Now;
post.postDescription = "cool post at " + DateTime.Now.ToString();
post.postGuid = Guid.NewGuid();
post.postTitle = "Post title";
post.postUpdatedDate = DateTime.Now;
post.Save();
}
public void ButtonUpdate_OnClick(object sender, EventArgs e) {
stPost post = stPost.All().ToList<stPost>()[0];
if (post != null && !post.IsNew()) {
post.postDescription = "cool post UPDATED at " + DateTime.Now.ToString();
post.postTitle = "Post title Updated";
post.postUpdatedDate = DateTime.Now;
post.Save();
}
}
以及更新
exec sp_executesql N'UPDATE [stPost]
SET postDescription=@up_postDescription,
postTitle=@up_postTitle,
postUpdatedDate=@up_postUpdatedDate
WHERE [dbo].[stPost].[postID] =
@0',N'@up_postDescription varchar(40),
@up_postTitle varchar(18),
@up_postUpdatedDate varchar(19),
@0 int',
@up_postDescription='cool post UPDATED at 14.07.2009 14:11:58',
@up_postTitle='Post title Updated',
@up_postUpdatedDate='14.07.2009 14:11:58',
@0=2
在插入和更新时,日期以不同的方式传递。解析'14.07.2009'会导致值超出范围。我想问题可能出在文化/全球化设置中的某个地方,因为我的本地文化设置为俄语,而sql server排序规则设置为西里尔文\u General\u CI\u AS。但问题并不是发生在插入时,而是发生在更新时。这让我觉得问题出在亚音速的某个地方。
任何帮助或想法都将不胜感激
Vladimir这仍然是3.0.0.2的问题吗?这看起来像一个bug。你能把这个记录在我们的问题列表上吗?如果可能的话,给我一个单元测试/模式,我可以用它重新编程吗?谢谢:)谢谢。我在这里将一个问题添加到github问题列表的subsonic3上
exec sp_executesql N'UPDATE [stPost]
SET postDescription=@up_postDescription,
postTitle=@up_postTitle,
postUpdatedDate=@up_postUpdatedDate
WHERE [dbo].[stPost].[postID] =
@0',N'@up_postDescription varchar(40),
@up_postTitle varchar(18),
@up_postUpdatedDate varchar(19),
@0 int',
@up_postDescription='cool post UPDATED at 14.07.2009 14:11:58',
@up_postTitle='Post title Updated',
@up_postUpdatedDate='14.07.2009 14:11:58',
@0=2