日期:2014-05-20  浏览次数:20976 次

Linq的YD问题(急,在线)

异常信息: 
    异常类型: InvalidCastException 
    异常消息: 无法将类型为“System.Int32”的对象强制转换为类型“System.String”。 
    堆栈跟踪:    在 System.Data.SqlClient.SqlBuffer.get_String()
   在 System.Data.SqlClient.SqlDataReader.GetString(Int32 i)
   在 Read_SmsTemplate(ObjectMaterializer`1 )
   在 System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()
   在 System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

执行linq查询,把IqueryAble 转化为toList 泛型时,报出上面错误。
诡异的是:表映射的实体类字段以及类型都与表中一一对应,没有问题。但是“偶尔”出现以上错误。
整个应用程序中,查询single<实体>时 还报出 “指定类型转换无效”,也是偶然的。

PS:映射的实体类都为正常。

谢谢!
------解决方案--------------------
关注中~

------解决方案--------------------

异常信息: 
    异常类型: FaultException`1 
    异常消息: 指定的转换无效。 
    堆栈跟踪:    在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
 在 sz1card1.Platform.IManagementService.CheckUserLogin(String& message, Guid businessguid, String userName, String password)
   在 sz1card1.Platform.ManagementServiceClient.CheckUserLogin(String& message, Guid businessguid, String userName, String password) 位置 c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\f31e14e2\9c08e304\App_WebReferences.wy7pn9wz.0.cs:行号 392
   在 Login.LogAction(Object sender, EventArgs e) 位置 e:\Management\Login.aspx.cs:行号 145
   在 System.Web.UI.HtmlControls.HtmlInputImage.OnServerClick(ImageClickEventArgs e)
   在 System.Web.UI.HtmlControls.HtmlInputImage.RaisePostBackEvent(String eventArgument)
   在 System.Web.UI.HtmlControls.HtmlInputImage.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 


------解决方案--------------------
关注!
------解决方案--------------------
抢个板凳。。。。
------解决方案--------------------
楼主你可以把你的IqueryAble ,toList 这两个的怎么转换的代码发出来看看吗? 只有错误信息很难定位。。。 
------解决方案--------------------

            IQueryable<SmsTemplate> list = from u in DataContext.SmsTemplate
                                           where u.KeyName == "customTemplate" && (u.BusinessGuid == businessGuid