我认为枚举可能是要走的路,并且根据操作(创建、删除)它会替换字符?然后我必须为“--”、“++”、“>=”和“>”hrrmm 存储一个变量。任何简单的建议都会很棒,我可以将其用作将来如何解决此类问题的参考!
public void ArrangeCategoriesOrderOnCreate(Category category)
{
var tx = _session.BeginTransaction();
var categories = _session.QueryOver<Category>()
.Where(c => c.Parent.Id == category.Parent.Id && c.OrderInList >= category.OrderInList) // the >= category.OrderInList here
.List<Category>();
foreach(var item in categories)
{
item.OrderInList++; // The ++ here.
_session.SaveOrUpdate(item);
}
tx.Commit();
}
public void ArrangeCategoriesOrderOnDelete(Category category)
{
var tx = _session.BeginTransaction();
var categories = _session.QueryOver<Category>()
.Where(c => c.Parent.Id == category.Parent.Id && c.OrderInList > category.OrderInList) // the > category.OrderInList here
.List<Category>();
foreach(var item in categories)
{
item.OrderInList--; // the -- here.
_session.SaveOrUpdate(item);
}
tx.Commit();
}
编辑 1
无法从 Invoke 确定成员类型,Invoke(value(CumbriaMD.Infrastructure.DataServices.CategoryDataServices+<> c_DisplayClass8).orderComparer, c.OrderInList, value(CumbriaMD.Infrastructure.DataServices.CategoryDataServices+<>c _DisplayClass8).category.OrderInList) , System.Linq.Expressions.InvocationExpression
痕迹:
[异常:无法从 Invoke 确定成员类型,Invoke(value(CumbriaMD.Infrastructure.DataServices.CategoryDataServices+<>c_ DisplayClass8).orderComparer, c.OrderInList, value(CumbriaMD.Infrastructure.DataServices.CategoryDataServices+<>c_DisplayClass8).category.OrderInList), System.Linq.Expressions.InvocationExpression] NHibernate.Impl.ExpressionProcessor.ProcessBooleanExpression(表达式表达式) +1113 NHibernate.Impl.ExpressionProcessor.ProcessExpression(表达式表达式) +114 NHibernate.Impl.ExpressionProcessor.ProcessAndExpression( BinaryExpression 表达式)+85 NHibernate.Impl.ExpressionProcessor.ProcessBinaryExpression(BinaryExpression 表达式)+124 NHibernate.Impl.ExpressionProcessor.ProcessExpression(表达式表达式)+95 NHibernate.Impl.ExpressionProcessor.ProcessLambdaExpression(LambdaExpression 表达式)+52 NHibernate.Impl.ExpressionProcessor。 ProcessExpression(表达式
1 expression) +39 NHibernate.Criterion.QueryOver
2.Add (表达式 2.Where(1 expression) +107 NHibernate.Criterion.QueryOver
表达式1 expression) +42 NHibernate.Criterion.QueryOver
2.NHibernate.IQueryOver.Where(表达式`1 表达式)+42