2024年1月6日发(作者:)

4、数据类型转换的帮助类g

namespace

{ ///

///

转换帮助类 ///

public static class UtilConvert { /// ///

///

/// /// public static int ObjToInt(this object thisValue) { int reval = 0; if (thisValue == null) return 0; if (thisValue != null && thisValue != && se(ng(), out reval)) { return reval; } return reval; } /// ///

///

/// /// /// public static int ObjToInt(this object thisValue, int errorValue) { int reval = 0; if (thisValue != null && thisValue != && se(ng(), out reval)) { return reval; } return errorValue; } /// ///

///

/// /// public static double ObjToMoney(this object thisValue) { double reval = 0; if (thisValue != null && thisValue != && se(ng(), out reval)) { return reval; } return 0; } /// ///

///

/// /// /// public static double ObjToMoney(this object thisValue, double errorValue) { double reval = 0; if (thisValue != null && thisValue != && se(ng(), out reval));

{ return reval; } return errorValue; } ///

///

///

/// /// public static string ObjToString(this object thisValue) { if (thisValue != null) return ng().Trim(); return ""; } /// ///

///

/// /// public static bool IsNotEmptyOrNull(this object thisValue) { return ObjToString(thisValue) != "" && ObjToString(thisValue) != "undefined" && ObjToString(thisValue) != "null"; } /// ///

///

/// /// /// public static string ObjToString(this object thisValue, string errorValue) { if (thisValue != null) return ng().Trim(); return errorValue; } /// ///

///

/// /// public static Decimal ObjToDecimal(this object thisValue) { Decimal reval = 0; if (thisValue != null && thisValue != && se(ng(), out reval)) { return reval; } return 0; } /// ///

///

/// /// /// public static Decimal ObjToDecimal(this object thisValue, decimal errorValue) { Decimal reval = 0; if (thisValue != null && thisValue != && se(ng(), out reval)) { return reval; } return errorValue; } ///

using

using

using

using

using

using

using

using

using

using

using

namespace

{;;;;;;;;;;; public class SystemUserDAL : FSqlBase { #region CURD(增删查改) public Task> GetList(int pageSize, int pageIndex, ref long count, Expression> where = null, string order

= null) { return ble() .WhereIf(where != null, where).Count(out count).Page(pageIndex, pageSize).OrderBy(!OrWhiteSpace(order), order).ToListAsync(); } public Task GetById(long id) { return ble().Where(it => == id).FirstAsync(); } public Task UpdateOrInsert(SystemUser item) { if (item?.Id > 0) { return ().SetSource(item) .IgnoreColumns(it => new { Time }) .ExecuteAffrowsAsync(); } else return (item).ExecuteAffrowsAsync(); } public Task Delete(long id) { return ().Where(it => == id).ExecuteAffrowsAsync(); } #endregion }}(业务逻辑层)UI层和DAL层之间的桥梁。实现业务逻辑。业务逻辑具体包含:验证、计算、业务规则等等。1、