asp.net mvc - The cast to value type 'System.Single' failed because the materialized value is null for stored procedure -
my stored procedure returns following data:
sensornodeuuid type val0 val1 val2 -------------------------------------------------- 88418344615647248 3 25.77 0 4.23 88418344615634456 3 null null null 88432552356623423 2 null null null 88418344584627440 3 24.77 0 4.29
i have model :
public class editsensormodel { public list<editsensormodel> editsensor; public int64 sensornodeuuid { get; set; } public int type { get; set; } public float val0 { get; set; } public float val1 { get; set; } public float val2 { get; set; } }
in controller:
list<editsensormodel> vendlist = new list<editsensormodel>(); var vnlist = entities.database.sqlquery<editsensormodel>("exec usp_getsensornode @userid", new sqlparameter("@userid", convert.toint32(session["userid"])) ).tolist(); foreach (var item in vnlist) { editsensormodel temp = new editsensormodel(); temp.sensornodeuuid = item.sensornodeuuid; temp.type = item.type; temp.val0 = item.val0 ; temp.val1 = item.val1 ; temp.val2 = item.val2 ; vendlist.add(temp); }
in controller, getting error storing data variable vnlist. error i'm facing is: cast value type 'system.single' failed because materialized value null. know how solve error
use float? in model.
float? val0; float? val1; float? val2;
Comments
Post a Comment