You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
766 B

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;
}
}
}