if (!string. IsNullOrEmpty (yt_time_limit_1)) {entity["yt_time_limit_1"] = Convert.todecimal (yt_time_ limit_1); } else {entity["yt_time_limit_1"] = "null"; }CD. Updatefaultcomponent (entity); public bool Updatefaultcomponent (entity entity) {StringBuilder strSQL = new StringBuilder (); Strsql.append ("Update yt_fault_component set"); Strsql.append ("yt_name=" + entity["yt_name"] + "',"); Strsql.append ("yt_fault_assembly=" + ((entityreference) entity["yt_fault_assembly"]). Id + "',"); Strsql.append ("yt_distance_7=" + entity["yt_distance_7"] + ""); Strsql.append ("Where yt_code= '" + entity["Yt_code"] + "'"); int rows = Convert.ToInt32 (Sqlhelper.sqlexecutescalar (strsql.tostring (), Sqlcon)); Return rows > 0? True:false; }
If you don't use CRM standard//crmservice here. Update (entity), standard null value is normal, custom Update method stitching SQL, update the word decimal is not allowed to be empty, but the business proposed can not be empty, to be null, this is a problem, if the direct assignment of NULL entiity passed would be "", The UPDATE statement will be an error, this problem has been my day,
If the direct assignment of 0 is not so much, but must be null, the solution is this way, the assignment of "null" is OK.
The decimal type cannot be empty, and the custom update updates the null value issue.