sql server 2008 - Saving C# decimal to SQL decimal(18,4) SQL -
this question has answer here:
- decimal precision , scale in ef code first 13 answers
i've got slight issue. have field customer wishes store 4 decimal places price (weird least still). far, i'm able commit 2 decimal places db.
i using code first entity saving , sql server 2008 r2 db. here have fore each.
purchaseorder.cs (code first)
public virtual decimal shippingcost { get; set; }
purchaseorderservice.cs (service layer save entity)
public virtual void updatepurchaseorder(purchaseorder purchaseorder) { if (purchaseorder == null) throw new argumentnullexception("purchase order"); _purchaseorderrepository.update(purchaseorder); }
purchaseorder table:
shippingcost decimal(18, 4) not null
ex. shipping cost input 10.5555 on ui. way down throught service layer, holds onto value. once hits sending entity save, db not keep values beyond 10.55.
theree entity framework default value uses 2 decimals.
decimal precision , scale in ef code first
shows how change that.
Comments
Post a Comment