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<T>(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<int>(sql, obj => (int)obj);
|
|
return new T() { ID = id, RowVersion = rowVersion };
|
|
}
|
|
|
|
public static bool EnsureStateSame<T>(T dmo)
|
|
where T : Entity, new()
|
|
{
|
|
var minDmo = LoadMinDmo<T>(dmo.TableName, dmo.ID);
|
|
return minDmo.RowVersion == dmo.RowVersion;
|
|
}
|
|
|
|
}
|
|
}
|