Sorting null value

Jun 30, 2014 at 2:04 PM
I have Classes
public class Transport
        public virtual int Id { get; set; } 
        public virtual string lic_plate { get; set; } /
        public virtual Class.CarModel Modelis { get; set; }
    public class CarModel
        public virtual int Id { get; set; }
        public virtual string model_name { get; set; }
And when i try to sort Modelis.model_name i get error Npgsql.NpgsqlException: ERROR: 2201X: OFFSET must not be negative
Jun 30, 2014 at 2:55 PM
Edited Jun 30, 2014 at 2:57 PM
looks like a db error, you should try to reproduce it without the grid

this might also be useful in your case
Jun 30, 2014 at 3:47 PM
Edited Jun 30, 2014 at 3:48 PM
It's not sql error(since it works with grid.mvc)

Here is some additional error (I get it because of this row:return Json(new GridModelBuilder<Transport>(list, g) ):
[ select transport0_.Id as Id150_, transport0_.lic_plate as lic2_150_, transport0_.model as model150_, transport0_.odometer as odometer150_, transport0_.moto_val as moto5_150_, transport0_.body_nr as body6_150_, transport0_.color as color150_, transport0_.made_date as made8_150_, transport0_.autoage as autoage150_, transport0_.buy_date as buy10_150_, transport0_.sell_date as sell11_150_, transport0_.travel_page as travel12_150_, transport0_.rajonas as rajonas150_, transport0_.region as region150_, transport0_.status as status150_, transport0_.category_tp as category16_150_, transport0_.trailer as trailer150_, transport0_.driver as driver150_, transport0_.owner as owner150_, transport0_.client as client150_, transport0_.fuel_type as fuel21_150_, transport0_.start_type as start22_150_, transport0_.fuel_capacity as fuel23_150_, transport0_.fuel_left as fuel24_150_, transport0_.fuel_rate as fuel25_150_, transport0_.moto_fuel_rate as moto26_150_, transport0_.spec_moto_fuel_rate as spec27_150_, transport0_.classs as classs150_, transport0_.type as type150_, transport0_.body_type as body30_150_, transport0_.spec_type as spec31_150_, transport0_.clasification as clasifi32_150_, transport0_.weight as weight150_, transport0_.engine_volume as engine34_150_, transport0_.sbtype as sbtype150_, transport0_.catalizator as cataliz36_150_, transport0_.sertificate as sertifi37_150_, transport0_.expiration_date as expiration38_150_ from transport transport0_ limit :p0 offset :p1 ]
  Name:p1 - Value:-10  Name:p2 - Value:10
P.s in my classes there are more values than I wrote before(thats why query is so long)

Seems that Offset is negative, and I can't figure out why is that?
Jun 30, 2014 at 4:03 PM
Edited Jun 30, 2014 at 4:04 PM
try to separate it:
  var gridModel = new GridModelBuilder<Transport>(list, g).Build({...});

  // also try to invoke the serializer manually


make use of Map , with EF and SQL Server sometimes there's errors on serialization because of lazy loading, when query gets executed circular references occur, using map you specify the fields that you need
Jul 1, 2014 at 7:16 AM
I use mapping, but should I specify all fields?
Talking about serializer (what kind of serializer should I use, since I get error)
The name 'serializer' does not exist in the current context
And separating gridmodel from return json does not fix error.

Thank you.
Jul 2, 2014 at 3:28 PM
Edited Jul 2, 2014 at 3:28 PM
specify the fields that you need to use in the column definition,
Map = o => new { o.Person, o.Food, Date = o.Date.ToString("dd MMMM yyyy"), o.Location },

you can do
            new Column { ClientFormat = ".Person was at .Location"},
            new Column { ClientFormat = ".Food" },
            new Column { Name = "Date"} // same as ClientFormat = ".Date" except here you also bind the column to grid model's Date property (not to the mapped model)