c# - Unable to cast the type 'DynamicClass1' to type <T>. LINQ to Entities only supports casting EDM primitive or enumeration types -


I tried for hours to find a solution for my issue but no posts help me.

I am trying to obtain a record from the database using the library (unit framework 6.0 / MVC 5.0) with the library.

  System.Linq.Dynamic;  

using the full code

  below (var entities = new vskdbEntities ()) {entity.DataFields = "id, stack_trace"; _list = entities.vsk_error_log .OrderBy (entity.Order) .Select ("New (" + entity.DataFields + ")") .Skip (entity.PageSize * entity.PageNumber) .ake (entity.PageSize) .Cast & LT ; Vsk_error_log & gt; () to create a list (); }  

But this result in the error in the work time

Type 'System.NotSupportedException' an exception occurred in EntityFramework.SqlServer.dll but was not handled in User code

Additional information: Unable to type 'DynamicClass1' to type 'VideoKit.framework.vsk_error_log', the body supports only EDM primitive or counting type casting from LINQ.

I know that the issue is being raised with the selection section, but the way to fix this casting issue is not known.

not updated 1:

If I try to use the code as shown below, then it will get the data properly

By using
  (var entities = new VskdbEntities ()) {var reference = ((System.Data.Entity.Infrastructure.IObjectContextAdapter) entities). Objectcoretext; Lst = context.CreateObjectSet & lt; Vsk_error_log & gt; (). AsEnumerable (). Select ("new (id, stack_trace)"). Cast & lt; DynamicClass & gt; (). ToList (); }  

but retrieved data with type

General list of systems. If I try to cast with appropriate class vsk_error_log instead of DynamicClass then I get the error

Unable to type 'VideoCit.framework' to cast an object of type 'DynamicClass1'

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -