Don't understand Error Message

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Don't understand Error Message

Post by Zero-G. » Wed 30 Sep 2009 11:39

Hey

I get an error message, which I don't understand...
The object of type "Devart.Data.Linq.DataQuery`1[VOPT.Voptneucontext.Kundenstamm]" could not be changed into Typ "VOPT.Voptneucontext.Kundenstamm".
(I transleted from the german version)
I try the following code:

Code: Select all

Dim MyKundensatmm As Voptneucontext.Kundenstamm
MyKundensatmm = From query In LinqProvider.GetProvider.Kundenstamms Where _
                           query.Kundenid = MyKundensatmm.Kundenid
StackTrace:
bei VOPT.frmHandelsware.cmdSpeichern_Click(Object sender, EventArgs e) in C:\Users\Intelli Soft\Documents\Visual Studio 2008\Projects\Visual OPT .NET - Kopie\Vopt\VOPT\UserControl\Handelsware\frmHandelsware.vb:Zeile 57.
bei System.Windows.Forms.Control.OnClick(EventArgs e)
bei Janus.Windows.EditControls.UIButton.OnClick(EventArgs e)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.RunDialog(Form form)
bei System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
bei System.Windows.Forms.Form.ShowDialog()
bei VOPT.ISAuftrag.cmdNeu_Click(Object sender, EventArgs e) in C:\Users\Intelli Soft\Documents\Visual Studio 2008\Projects\Visual OPT .NET - Kopie\Vopt\VOPT\UserControl\Basis\ISAuftrag.vb:Zeile 102.
bei System.Windows.Forms.Control.OnClick(EventArgs e)
bei Janus.Windows.EditControls.UIButton.OnClick(EventArgs e)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei VOPT.VisualOPTNet.Initialize() in C:\Users\Intelli Soft\Documents\Visual Studio 2008\Projects\Visual OPT .NET - Kopie\Vopt\VOPT\Modul\VisualOPTNet.vb:Zeile 33.
bei VOPT.Start.Main() in C:\Users\Intelli Soft\Documents\Visual Studio 2008\Projects\Visual OPT .NET - Kopie\Vopt\VOPT\Modul\Start.vb:Zeile 26.
bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()[/code]

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 01 Oct 2009 15:12

Try adding Single() or First() to your query like in the following code:

Code: Select all

Dim MyKundensatmm As Voptneucontext.Kundenstamm 
MyKundensatmm = (From query In LinqProvider.GetProvider.Kundenstamms Where _ 
                           query.Kundenid = MyKundensatmm.Kundenid).Single()

Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Fri 02 Oct 2009 10:15

Thanks -That's it

Post Reply