vb.net - LINQ to SQL delete producing "Specified cast is not valid" error -


I have found a painkiller simple table that is giving a "specified artist not valid" error while trying to delete me One or more rows have two columns in the table, in the form of an "id" primary key (INT), and "name" (VARCHAR (20)), which is the map for LINQ from LINQ to a string in the SQL dbml file. Both of these statements generated error:

  dc.DeleteOnSubmit (dc.MyTables.Where (function (x) x.id = 1) .SingleOrDefault) dc.DeleteAllOnSubmit (dc.MyTables) << / P> 
  • id = 1, name = "/> first"
  •   [InvalidCastException: specified cast is not valid is.] System.Data.Linq.SingleKeyManager`2.TryCreateKeyFromValues ​​(object [] values, V & amp; V) +59 system .Data.Linq.IdentityCache`2.Find (object [] keyValues) +28 system .Data.Linq.StandardIdentityManager.Find (MetaType type, vas Ye [] keyValues) +23 System.Data.Linq.CommonDataServices.GetCachedObject (MetaType type ,, object [] keyValues) +48 System.Data.Linq.ChangeProcessor.GetOtherItem (MetaAssociation Assoc instance object) 142 System.Data.Linq. Changeprosessorkbuildedgemps () +233 Systemkdetaklinkkchangeprosessorksubechanges (Confliktmode Filuremode) +59 Systemkdetaklinkkdtkntestksubechanges (Confliktmode Filuremode) 331 Systemkdetaklinkkdtkntestksubechanges () +19 InpatientCensus .MaintenanceController.DeleteSoleCommunity (Int32 ID) C: \ Documents and Settings \ gregf \ My Documents \ Projects \ inpatientCensus \ inpatientCensus \ Controller \ Maintenance Controller VB: 14 Lam bda_method (ExecutionScope, ControllerBase, Object []) 128 System.Web.Mvc.ActionMethodDispatcher.Execute (ControllerBase controller, Object [] parameters) +17 System.Web.Mvc.ReflectedActionDescriptor.Execute (ControllerContext controllerContext, IDictionary` 2 parameter) +178 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (Controller Contact Controller Contintbox, Action Descriptor Action Descriptor, IDCIR2 Parameter) +24 System Web. MVC & Lt; & Gt; C__DisplayClassa & Lt; InvokeActionMethodWithFilters & gt; B__7 () +52 system. Web. Mvc.ControllerActionInvoker.InvokeActionMethodFilter (IActionFilter Filter, Action Accepting Contact Precontext, Funk 1 Issue) +254 System. Web. MVC And lt; & Gt; C__DisplayClassc & Lt; InvokeActionMethodWithFilters & gt; b__9 () +19 system. Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters (controller consultant controller context, Aiaielaiti 1 filter, Akshndeskriptr action descriptor, Aidiviki`2 parameter) +192 system. Web. MVC Kantrolrakt ionInvoker.InvokeAction (ControllerContext controllerContext, string actionName) 399 System.Web.Mvc.Controller.ExecuteCore () 126 System.Web.Mvc.ControllerBase.Execute (RequestContext requestContext) +27 System.Web.Mvc.ControllerBase.System. Web.Mvc.IController.Execute (RequestContext RequestContax) +7 system. Web. MVC MVC handler Process Requests (HTTPTPTXBSE HTQuext) +151 System. Web. MVCMVC handler Process Requests (HTTTTNTX HTQIntex) +57 System Web. MVCMVC Handler. System Web. IHTTPAndler Process Requests (HTTP Contact http Contestex) +7 System. Web. Callhandler Execution Stop System Web. Http application IECCUTION TIPP.EXECTUIT () +181 SYSTEMS. Web. HTTPApplication.exelectstep (IEExulation phase, boolean & full synchronous) +75  

    Rows removed can be removed by removing the added association in the DBML file. Why would the association cause the error? The associated columns are resolved in both VARCHAR (20) databases and in the dbml file.

    What could possibly be a casting error?

OK, upon viewing the update, this issue is the connection between your two tables. It is known in .NET 3.5 SP1 and will be fixed in .NET 4.0. If you can, try your code on .NET 4.0 Beta.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -