Beispiel #1
0
        public SqlProvider <T> FormatUpdateZhanglei <TKey>(Expression <Func <T, TKey> > expression, TKey value)
        {
            MemberExpression m = expression.Body as MemberExpression;

            if (m == null)
            {
                var mbs = new ExpressionPropertyFinder(expression, typeof(T)).MemberList;
                if (!mbs.Any())
                {
                    throw new FieldAccessException($"未在更新表达式中找到类型 {typeof(T).Name} 的任何字段");
                }
            }

            var update = ResolveExpression.Instance(Dialect).ResolveUpdateZhanglei <T>(expression, value);

            var where = ResolveExpression.Instance(Dialect).ResolveWhere(Context.CommandSet.WhereExpression);

            var whereSql = where.SqlCmd;

            Params = where.Param;
            Params.AddDynamicParams(update.Param);

            SqlString = $"UPDATE {FormatTableName(false)} {update.SqlCmd} {whereSql}";

            return(this);
        }
Beispiel #2
0
        public void Test1()
        {
            List <Expression <Func <TheModel, object> > > list = new List <Expression <Func <TheModel, object> > >();

            list.Add(x => x.Id);
            list.Add(x => x.Name);
            var epf    = new ExpressionPropertyFinder(list[0], typeof(TheModel));
            var result = epf.MemberList;
        }