Well, we decided to go back DI solution. Here is the code I plan to use. Pls. let me know if I made any mistake
. We do not want to this class depend on any LLBL Generated code is possible.
using System;
using System.Reflection;
using CSRS.LLBLGenPro;
using SD.LLBLGen.Pro.ORMSupportClasses;
namespace CSRS.LLBLGenPro
{
class GeneralConcurrencyControl : IConcurrencyPredicateFactory
{
public IPredicateExpression CreatePredicate(
ConcurrencyPredicateType predicateTypeToCreate, object containingEntity)
{
EntityBase2 entity = (EntityBase2)containingEntity;
IPredicateExpression expression = new PredicateExpression();
EntityFields2 timestampField = (EntityFields2) predicateTypeToCreate.GetType().InvokeMember("GetFieldsInfo", BindingFlags.InvokeMethod, null, predicateTypeToCreate, null);
switch (predicateTypeToCreate)
{
case ConcurrencyPredicateType.Save:
expression.Add(((EntityField2)timestampField["ConcurrencyTimeStamp"]) == entity.Fields["ConcurrencyTimeStamp"].DbValue);
break;
}
return expression;
}
}
}