using System; using System.Collections.Generic; using System.Linq; using System.Text; using WeighBusiness.BO; using WeighBusiness.Utils; using WeighBusiness.Utils.SqlUtils; namespace WeighBusiness.BL { public static class EntityBL { public static T LoadMinDmo(string tableName, long id) where T : Entity, new() { const string querySql = "select RowVersion from {0} where id={1}"; var sql = querySql.FormatWith(tableName, id); var rowVersion = SqlHelperEx.DoQuery(sql, obj => (int)obj); return new T() { ID = id, RowVersion = rowVersion }; } public static bool EnsureStateSame(T dmo) where T : Entity, new() { var minDmo = LoadMinDmo(dmo.TableName, dmo.ID); return minDmo.RowVersion == dmo.RowVersion; } } }