开发者

Linq-to-SQL cast exception with stored procedure that returns unnamed column

I don't own the SP, but it returns a dataset with columns with names like:

FileID, SomethingNormal, Foo, Bar, SUM(bleh)

SUM(bleh) is unnamed. I add the stored proc using the dbml tool in VS2010 and it detects SUM(bleh) as Column1 and gives it an int type, which sounds alright.

However, when trying to run, the moment it tries to get the IEnumerable, it breaks by giving an error:

Specified cast is not valid.

Unhandled Exception: System.InvalidCastException: Specified cast is not valid. at System.Data.SqlClient.SqlBuffer.get_Int32() at System.Data.SqlClient.SqlDataReader.GetInt32(Int32 i) at Read_RejectedRecordsHourlyBySubscriptionResult(ObjectMaterializer1 ) at System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader2.MoveNext()

That happens the moment I try to iterate or if I get the enumerate manually.

In a dev environment I did SUM(bleh) as TotalBleh (rest assured all this names are fake >_>) and I had no issues with what I've done.

Anything I should know? Thanks!

EDIT:

This appears to be a bug wit开发者_如何学编程h Linq-to-SQL. Strangely, the bug report says it supports -ONE- anonymous column (although no more) and in this case there is only one.

I will do it with basic SqlCommand and stuff. So much for commodity.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜