zoukankan      html  css  js  c++  java
  • 验证某字段的唯一性

    var parameter = Expression.Parameter(typeof(AttendeeTable), "t");

    // 会议id
    var bventLeftExpression = Expression.PropertyOrField(parameter, nameof(AttendeeTable.BventId));
    var bventRightExpresion = Expression.Constant(bventId, typeof(string));
    var bventCompare = Expression.Equal(bventLeftExpression, bventRightExpresion);

    // 字段
    var leftExpression = Expression.PropertyOrField(parameter, fieldName);
    var rightExpression = Expression.Constant(value, attendeeProperty.PropertyType);
    var compare = Expression.Equal(leftExpression, rightExpression);

    // and关联
    var expression = Expression.AndAlso(bventCompare, compare);

    var realExpression = Expression.Lambda<Func<AttendeeTable, bool>>(expression, parameter);
    var count = await _attendeeDataAccess.GetCountAsync(realExpression);
    return count > 0;

  • 相关阅读:
    113. Path Sum II
    112. Path Sum
    111. Minimum Depth of Binary Tree
    110. Balanced Binary Tree
    Create
    SetWindowPos
    INT_PTR数据类型
    SDK介绍
    COLORREF
    setfont()函数
  • 原文地址:https://www.cnblogs.com/sunnie/p/10840118.html
Copyright © 2011-2022 走看看