Example #1
0
 /// <summary>
 /// 创建分组表达式。
 /// </summary>
 /// <param name="source">源表达式。</param>
 /// <param name="keypro">分组键的CLR描述对象。</param>
 /// <param name="key">分组键表达式。</param>
 /// <param name="item">单元项表达式,用于自定义创建分组项表达式。</param>
 public DbGroupByExpression(DbUnitTypeExpression source, PropertyInfo keypro, DbExpression key, DbUnitItemTypeExpression item)
     : base(source.ClrType, new DbGroupItemExpression(item))
 {
     Source      = source;
     KeyProperty = keypro;
     Key         = key;
 }
Example #2
0
 /// <summary>
 /// 创建SELECT查询表达式。
 /// </summary>
 /// <param name="source">源数据单元表达式。</param>
 /// <param name="itemType">单元数据项CLR类型。</param>
 public DbSelectExpression(DbUnitTypeExpression source, DbUnitItemTypeExpression itemType)
     : base(typeof(IQueryable <>).MakeGenericType(itemType.ClrType), source, itemType)
 {
 }
Example #3
0
 /// <summary>
 /// 创建笛卡尔积连接表达式。
 /// </summary>
 /// <param name="source">源表达式。</param>
 /// <param name="target">目标表达式。</param>
 /// <param name="newExp">连接后输出的项表达式。</param>
 public DbCrossJoinExpression(DbUnitTypeExpression source, DbUnitTypeExpression target, DbUnitItemTypeExpression newExp)
     : base(typeof(IQueryable <>).MakeGenericType(newExp.ClrType), source, newExp)
 {
     Target = target;
 }
Example #4
0
        /// <summary>
        /// 创建内连接操作表达式。
        /// </summary>
        /// <param name="source">源表达式。</param>
        /// <param name="target">目标表达式。</param>
        /// <param name="left">左端匹配键表达式。</param>
        /// <param name="right">左端匹配键表达式。</param>
        /// <param name="newExp">连接后输出的新对象表达式,该成员是LINQ连接体系中所必须的。</param>
        public DbInnerJoinExpression(DbUnitTypeExpression source, DbUnitTypeExpression target, DbExpression left, DbExpression right, DbUnitItemTypeExpression newExp)
            : base(typeof(IQueryable <>).MakeGenericType(newExp.ClrType), source, newExp)
        {
            Target = target;
            switch (left.ExpressionType)
            {
            case EExpressionType.MemberAccess:
                KeyPairs = new DbJoinKeyPairExpression[] { new DbJoinKeyPairExpression(left, right) };
                break;

            case EExpressionType.New:
                KeyPairs = (from a in ((DbNewExpression)left).Members
                            join b in ((DbNewExpression)right).Members on a.Key equals b.Key
                            select new DbJoinKeyPairExpression(a.Value, b.Value)).ToArray();
                break;

            default:
                throw new NotSupportedException(string.Format(Res.NotSupportedExpressionParseInnerJoinKeyPairs, left.ExpressionType));
            }
        }
Example #5
0
 /// <summary>
 /// 创建单元类型表达式。
 /// </summary>
 /// <param name="type">数据项CLR类型。</param>
 /// <param name="itemType">数据项表达式。</param>
 public DbUnitTypeExpression(Type type, DbUnitItemTypeExpression itemType)
 {
     ClrType = type;
     ReplaceItem(itemType);
 }
Example #6
0
 /// <summary>
 /// 替换当前的数据项表达式。
 /// </summary>
 /// <param name="item">替换表达式。</param>
 /// <returns>当前单元表达式。</returns>
 public DbUnitTypeExpression ReplaceItem(DbUnitItemTypeExpression item)
 {
     Item      = item;
     item.Unit = this;
     return(this);
 }
Example #7
0
 /// <summary>
 /// 初始化数据集操作。
 /// </summary>
 /// <param name="type">数据集的元素CLR类型。</param>
 /// <param name="source">操作的单元表达式。</param>
 /// <param name="itemType">单元项表达式。</param>
 public DbSetOperationExpression(Type type, DbUnitTypeExpression source, DbUnitItemTypeExpression itemType)
     : base(type, itemType)
 {
     Source = source;
 }