linq - Dynamic sorting with nullable coulmn -


I am writing dynamic sorting with lambda expression such as:

  string sortColumn = imageFilterType = = 1? "Created": "Abuse"; Var paramExp = expression.Pameter (typef (item), typef (item) .ostring ()); Expression propConvExp = expression. Convert (expression. Properties (paramx, sort code), typef (object)); Var sortxp = expression Lambda & lt; Funk & lt; Items, objects & gt; & Gt; (Proponxpec, Permanence XP); After this I am creating dynamic sort column and I am implementing this type of extension in Bile query:  
  var item = _db Items.AsQueryable () .expandable () .user (sortexp). Where (ingenious) Select (x = & gt; x). (_db.Users, i = & gt; i.UserId, u = & gt; u.UserID, (i, u) = & gt; new {i, absolute name = u.UserType == 1? U.FirstName + " "+ U.LastName: u.CompanyName, u.UserType, u.UserName}. Ollist () .Skip (Page Index) (page size);   

In my input there are 2 columns, through which I have been made one and the second is Abusecount. I have to sort them between columns with a column. But as I am trying to run the above code, I am getting the error:

Unable to type 'System.Nullable' 1 unable to type 'System.Object' EDM Primitive or Count Type Casting. "

Since both columns in my database are a faucet type, I am getting this problem. Is anyone the solution to this problem? I do not want to change DB. I have to solve it from the end of the end

Try this, it is very easy:

  var items = _db.Items.AsQueryable (). Espexable (); If (imageFilterType == 1) item = item Orderbidescoding (a => one. Rated); Other objects = items.orderbidescoding (a => a.AbuseCount); Item = item Where (diagnosis). Select (x = & gt; x). (_db.Users, i = & gt; i.UserId, u = & gt; u.UserID, (i, u) = & gt; new {i, full name = u.usr type == 1? U.FirstName + "" + U.LastName: u.CompanyName, u.UserType, u.UserName}). Skip (Page Index) Take (Page Size) .Olist ();    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -