mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 增加 ISelect`1.WithSql("select * from user ...") 功能;
This commit is contained in:
		@@ -1707,6 +1707,14 @@
 | 
			
		||||
            <param name="then">即能 ThenInclude,还可以二次过滤(这个 EFCore 做不到?)</param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:FreeSql.ISelect`1.WithSql(System.String)">
 | 
			
		||||
            <summary>
 | 
			
		||||
            实现 select .. from ( select ... from t ) a 这样的功能<para></para>
 | 
			
		||||
            使用 AsTable 方法也可以达到效果
 | 
			
		||||
            </summary>
 | 
			
		||||
            <param name="sql">SQL语句</param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:FreeSql.ISelectFromExpression`1.Where(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
 | 
			
		||||
            <summary>
 | 
			
		||||
            查询条件,Where(a => a.Id > 10),支持导航对象查询,Where(a => a.Author.Email == "2881099@qq.com")
 | 
			
		||||
 
 | 
			
		||||
@@ -369,5 +369,13 @@ namespace FreeSql
 | 
			
		||||
        /// <param name="then">即能 ThenInclude,还可以二次过滤(这个 EFCore 做不到?)</param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        ISelect<T1> IncludeMany<TNavigate>(Expression<Func<T1, IEnumerable<TNavigate>>> navigateSelector, Action<ISelect<TNavigate>> then = null) where TNavigate : class;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 实现 select .. from ( select ... from t ) a 这样的功能<para></para>
 | 
			
		||||
        /// 使用 AsTable 方法也可以达到效果
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="sql">SQL语句</param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        ISelect<T1> WithSql(string sql);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -329,6 +329,16 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public ISelect<T1> WithSql(string sql)
 | 
			
		||||
        {
 | 
			
		||||
            this.AsTable((type, old) =>
 | 
			
		||||
            {
 | 
			
		||||
                if (type == _tables.First().Table?.Type) return $"( {sql} )";
 | 
			
		||||
                return old;
 | 
			
		||||
            });
 | 
			
		||||
            return this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool Any(Expression<Func<T1, bool>> exp) => this.Where(exp).Any();
 | 
			
		||||
 | 
			
		||||
        public TReturn ToOne<TReturn>(Expression<Func<T1, TReturn>> select) => this.Limit(1).ToList(select).FirstOrDefault();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user