c#

cannot convert type decimal to double  #angularjs #reactjs

  • You have to convert the values to the necessary target type.
  • The decimal has more significant figures than the double it can be more precise and it also takes up slightly more memory.
  • Select(p => new AddressALL { UID_NUM = p.UID_NUM, ADD_FULL = p.ADD_FULL, POSTALCITY = p.POSTALCITY, ZIP5 = p.ZIP5}).ToArray(); } } catch (Exception) { return null; } } } public class AddressALL { public double UID_NUM { get; set; } public string TLID { get; set; } public string ADD_FULL { get; set; } public string POSTALCITY { get; set; } public string STATE { get; set; } public string ZIP5 { get; set; } public string IN_OUT { get; set; } }
  • if you put your comment in answer, I will mark it as answered.
  • Stack Overflow works best with JavaScript enabled

I have a simple web service calling a sql view table through entity framework. I can bring all the columns in string fine but not the column in numeric like UID_NUM(numeric(38,8), null) in SQL. I have AddressALL class to set columns like below and error out at p.UID_NUM in LINQ.

@ng_real_ninja: cannot convert type decimal to double #angularjs #reactjs

I have a simple web service calling a sql view table through entity framework. I can bring all the columns in string fine but not the column in numeric like UID_NUM(numeric(38,8), null) in SQL. I have AddressALL class to set columns like below and error out at p.UID_NUM in LINQ.

public class GISAddressWebService : System.Web.Services.WebService { [WebMethod] public AddressALL[] getAddress() { try { List address = new List(); using (GISAddressEntities database = new GISAddressEntities()) { return database.view_COBADDRESS .Where(p => p.UNIT_NUM == “103”) .Select(p => new AddressALL { UID_NUM = p.UID_NUM, ADD_FULL = p.ADD_FULL, POSTALCITY = p.POSTALCITY, ZIP5 = p.ZIP5}).ToArray(); } } catch (Exception) { return null; } } } public class AddressALL { public double UID_NUM { get; set; } public string TLID { get; set; } public string ADD_FULL { get; set; } public string POSTALCITY { get; set; } public string STATE { get; set; } public string ZIP5 { get; set; } public string IN_OUT { get; set; } }

The obvious solution, instead of

write

. Therefore you have to convert the values to the necessary target type.

The decimal has more significant figures than the double, therefore it can be more precise and it also takes up slightly more memory. Because of this difference fou must explicitly program this change of type through (double)p.UID_NUM.

c#

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.