The decimal type cannot be empty, and the custom update updates the null value issue.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.