Problem with Image and varbinary fields

4 posts, 0 answers
  1. bin
    bin avatar
    11 posts
    Member since:
    Jun 2010

    Posted 05 Jun 2011 Link to this post

    Hi sir,
    I am using the following code to return two fields from the table TestTable where the field FileContent datatype is Image or VarBinary .

    var q = (from tt in objScope.Extent<TestTable>()
                      select new { tt.FileID, tt.FileContent }).ToList();

    I got the following exception:-
    System.InvalidCastException was unhandled
      Message=Object must implement IConvertible.
      Source=mscorlib
      StackTrace:
           at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
           at Telerik.OpenAccess.Query.NullableConverter`1.Convert(ResultData& data)
           at Telerik.OpenAccess.Query.ArrayConverter`1.Convert(ResultData& data)
           at Telerik.OpenAccess.Query.ObjectConstructor.Convert(ResultData& data)
           at Telerik.OpenAccess.Query.TypedEnumerator`1.ObtainCurrent()
           at Telerik.OpenAccess.Query.TypedEnumerator`1.System.Collections.Generic.IEnumerator<T>.get_Current()
         ... Local paths ...

           at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ButtonBase.WndProc(Message& m)
           at System.Windows.Forms.Button.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at  ... Local paths ...
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:
  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 06 Jun 2011 Link to this post

    Hello bin,

    the issue has been fixed already, and the next build will contain the needed changes. As a workaround you can first do an empty projection, and then use the persistent field to perform the projection. 

    All the best,
    Thomas
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
  3. DevCraft banner
  4. bin
    bin avatar
    11 posts
    Member since:
    Jun 2010

    Posted 07 Jun 2011 Link to this post

    Hello Sir,

    What do you mean by " you can first do an empty projection, and then use the persistent field to perform the projection " ?
    Could you please provide me with a code sample for the empty projection that handles my case.

    Thanks
  5. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 07 Jun 2011 Link to this post

    Hi bin,

    I meant

    var q = (from tt in objScope.Extent<TestTable>()
             select tt).ToList().Select(xx => new { xx.FileID, xx.FileContent });

    So, first perform no projection and thus get real persistent instances back, then use the instances to get the field value. Please make sure that the FileContent is
    using the default fetch group too.

    All the best,
    Thomas
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
Back to Top