Interface ISelect<T1>
Assembly: FreeSql.dll
Syntax
public interface ISelect<T1> : ISelect0<ISelect<T1>, T1>, ISelect0
Type Parameters
Methods
|
Improve this Doc
View Source
Aggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, TReturn>>, out TReturn)
执行SQL查询,返回指定字段的聚合结果给 output 参数
fsql.Select<T>()
.Aggregate(a => new { count = a.Count, sum = a.Sum(a.Key.Price) }, out var agg)
.Page(1, 10).ToList();
Declaration
ISelect<T1> Aggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, TReturn>> select, out TReturn result)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<ISelectGroupingAggregate<T1>, TReturn>> |
select |
|
TReturn |
result |
|
Returns
Type Parameters
|
Improve this Doc
View Source
Any(Expression<Func<T1, Boolean>>)
Declaration
bool Any(Expression<Func<T1, bool>> exp)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, System.Boolean>> |
exp |
lambda表达式
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
AnyAsync(Expression<Func<T1, Boolean>>, CancellationToken)
Declaration
Task<bool> AnyAsync(Expression<Func<T1, bool>> exp, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, System.Boolean>> |
exp |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Boolean> |
|
|
Improve this Doc
View Source
As(String)
Declaration
ISelect<T1> As(string alias = "a")
Parameters
Type |
Name |
Description |
System.String |
alias |
别名
|
Returns
|
Improve this Doc
View Source
Avg<TMember>(Expression<Func<T1, TMember>>)
Declaration
double Avg<TMember>(Expression<Func<T1, TMember>> column)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
列
|
Returns
Type |
Description |
System.Double |
|
Type Parameters
Name |
Description |
TMember |
返回类型
|
|
Improve this Doc
View Source
AvgAsync<TMember>(Expression<Func<T1, TMember>>, CancellationToken)
Declaration
Task<double> AvgAsync<TMember>(Expression<Func<T1, TMember>> column, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Double> |
|
Type Parameters
|
Improve this Doc
View Source
First<TDto>()
执行SQL查询,返回 TDto 映射的字段,记录不存在时返回 Dto 默认值
Declaration
Returns
Type Parameters
|
Improve this Doc
View Source
First<TReturn>(Expression<Func<T1, TReturn>>)
执行SQL查询,返回指定字段的记录的第一条记录,记录不存在时返回 TReturn 默认值
Declaration
TReturn First<TReturn>(Expression<Func<T1, TReturn>> select)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
选择列
|
Returns
Type Parameters
Name |
Description |
TReturn |
返回类型
|
|
Improve this Doc
View Source
FirstAsync<TReturn>(Expression<Func<T1, TReturn>>, CancellationToken)
Declaration
Task<TReturn> FirstAsync<TReturn>(Expression<Func<T1, TReturn>> select, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<TReturn> |
|
Type Parameters
|
Improve this Doc
View Source
FirstAsync<TDto>(CancellationToken)
Declaration
Task<TDto> FirstAsync<TDto>(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<TDto> |
|
Type Parameters
|
Improve this Doc
View Source
From<T2>(Expression<Func<ISelectFromExpression<T1>, T2, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2> From<T2>(Expression<Func<ISelectFromExpression<T1>, T2, ISelectFromExpression<T1>>> exp = null)
where T2 : class
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ISelectFromExpression<T1>>> |
exp |
|
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
T11 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ISelectFromExpression<T1>>> |
exp |
|
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
T11 |
|
T12 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ISelectFromExpression<T1>>> |
exp |
|
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
T11 |
|
T12 |
|
T13 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ISelectFromExpression<T1>>> |
exp |
|
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
T11 |
|
T12 |
|
T13 |
|
T14 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ISelectFromExpression<T1>>> |
exp |
|
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
T11 |
|
T12 |
|
T13 |
|
T14 |
|
T15 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> From<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class where T11 : class where T12 : class where T13 : class where T14 : class where T15 : class where T16 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, ISelectFromExpression<T1>>> |
exp |
|
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
T11 |
|
T12 |
|
T13 |
|
T14 |
|
T15 |
|
T16 |
|
|
Improve this Doc
View Source
From<T2, T3>(Expression<Func<ISelectFromExpression<T1>, T2, T3, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3> From<T2, T3>(Expression<Func<ISelectFromExpression<T1>, T2, T3, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3> |
|
Type Parameters
|
Improve this Doc
View Source
From<T2, T3, T4>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4> From<T2, T3, T4>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3, T4> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5> From<T2, T3, T4, T5>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6> From<T2, T3, T4, T5, T6>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7> From<T2, T3, T4, T5, T6, T7>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7, T8> From<T2, T3, T4, T5, T6, T7, T8>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7, T8> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> From<T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
|
Improve this Doc
View Source
From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>>)
Declaration
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> From<T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> exp = null)
where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<ISelectFromExpression<T1>, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression<T1>>> |
exp |
|
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
|
Improve this Doc
View Source
FromQuery<T2>(ISelect<T2>)
Declaration
ISelect<T1, T2> FromQuery<T2>(ISelect<T2> select2)
where T2 : class
Parameters
Type |
Name |
Description |
ISelect<T2> |
select2 |
|
Returns
Type Parameters
|
Improve this Doc
View Source
FromQuery<T2, T3>(ISelect<T2>, ISelect<T3>)
Declaration
ISelect<T1, T2, T3> FromQuery<T2, T3>(ISelect<T2> select2, ISelect<T3> select3)
where T2 : class where T3 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3> |
|
Type Parameters
|
Improve this Doc
View Source
FromQuery<T2, T3, T4>(ISelect<T2>, ISelect<T3>, ISelect<T4>)
Declaration
ISelect<T1, T2, T3, T4> FromQuery<T2, T3, T4>(ISelect<T2> select2, ISelect<T3> select3, ISelect<T4> select4)
where T2 : class where T3 : class where T4 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3, T4> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
|
Improve this Doc
View Source
FromQuery<T2, T3, T4, T5>(ISelect<T2>, ISelect<T3>, ISelect<T4>, ISelect<T5>)
Declaration
ISelect<T1, T2, T3, T4, T5> FromQuery<T2, T3, T4, T5>(ISelect<T2> select2, ISelect<T3> select3, ISelect<T4> select4, ISelect<T5> select5)
where T2 : class where T3 : class where T4 : class where T5 : class
Parameters
Returns
Type |
Description |
ISelect<T1, T2, T3, T4, T5> |
|
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
|
Improve this Doc
View Source
GroupBy<TKey>(Expression<Func<T1, TKey>>)
按选择的列分组,GroupBy(a => a.Name) | GroupBy(a => new{a.Name,a.Time})
Declaration
ISelectGrouping<TKey, T1> GroupBy<TKey>(Expression<Func<T1, TKey>> exp)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TKey>> |
exp |
|
Returns
Type Parameters
|
Improve this Doc
View Source
Include<TNavigate>(Expression<Func<T1, TNavigate>>)
贪婪加载导航属性,如果查询中已经使用了 a.Parent.Parent 类似表达式,则可以无需此操作
Declaration
ISelect<T1> Include<TNavigate>(Expression<Func<T1, TNavigate>> navigateSelector)
where TNavigate : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TNavigate>> |
navigateSelector |
选择一个导航属性
|
Returns
Type Parameters
Name |
Description |
TNavigate |
|
|
Improve this Doc
View Source
IncludeByPropertyName(String)
按属性名字符串进行 Include/IncludeMany 操作
Declaration
ISelect<T1> IncludeByPropertyName(string property)
Parameters
Type |
Name |
Description |
System.String |
property |
|
Returns
|
Improve this Doc
View Source
IncludeByPropertyName(String, Expression<Action<ISelect<Object>>>)
Declaration
ISelect<T1> IncludeByPropertyName(string property, Expression<Action<ISelect<object>>> then)
Parameters
Type |
Name |
Description |
System.String |
property |
|
System.Linq.Expressions.Expression<System.Action<ISelect<System.Object>>> |
then |
|
Returns
|
Improve this Doc
View Source
IncludeByPropertyNameIf(Boolean, String)
按属性名字符串进行 Include/IncludeMany 操作
Declaration
ISelect<T1> IncludeByPropertyNameIf(bool condition, string property)
Parameters
Type |
Name |
Description |
System.Boolean |
condition |
true 时生效
|
System.String |
property |
|
Returns
|
Improve this Doc
View Source
IncludeByPropertyNameIf(Boolean, String, Expression<Action<ISelect<Object>>>)
Declaration
ISelect<T1> IncludeByPropertyNameIf(bool condition, string property, Expression<Action<ISelect<object>>> then)
Parameters
Type |
Name |
Description |
System.Boolean |
condition |
|
System.String |
property |
|
System.Linq.Expressions.Expression<System.Action<ISelect<System.Object>>> |
then |
|
Returns
|
Improve this Doc
View Source
IncludeIf<TNavigate>(Boolean, Expression<Func<T1, TNavigate>>)
贪婪加载导航属性,如果查询中已经使用了 a.Parent.Parent 类似表达式,则可以无需此操作
Declaration
ISelect<T1> IncludeIf<TNavigate>(bool condition, Expression<Func<T1, TNavigate>> navigateSelector)
where TNavigate : class
Parameters
Type |
Name |
Description |
System.Boolean |
condition |
true 时生效
|
System.Linq.Expressions.Expression<System.Func<T1, TNavigate>> |
navigateSelector |
选择一个导航属性
|
Returns
Type Parameters
Name |
Description |
TNavigate |
|
|
Improve this Doc
View Source
IncludeMany<TNavigate>(Expression<Func<T1, IEnumerable<TNavigate>>>, Action<ISelect<TNavigate>>)
贪婪加载集合的导航属性,其实是分两次查询,ToList 后进行了数据重装
文档:https://github.com/dotnetcore/FreeSql/wiki/%E8%B4%AA%E5%A9%AA%E5%8A%A0%E8%BD%BD
Declaration
ISelect<T1> IncludeMany<TNavigate>(Expression<Func<T1, IEnumerable<TNavigate>>> navigateSelector, Action<ISelect<TNavigate>> then = null)
where TNavigate : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, System.Collections.Generic.IEnumerable<TNavigate>>> |
navigateSelector |
选择一个集合的导航属性,如: .IncludeMany(a => a.Tags)
可以 .Where 设置临时的关系映射,如: .IncludeMany(a => a.Tags.Where(tag => tag.TypeId == a.Id))
可以 .Take(5) 每个子集合只取5条,如: .IncludeMany(a => a.Tags.Take(5))
可以 .Select 设置只查询部分字段,如: (a => new TNavigate { Title = a.Title })
|
System.Action<ISelect<TNavigate>> |
then |
即能 ThenInclude,还可以二次过滤(这个 EFCore 做不到?)
|
Returns
Type Parameters
Name |
Description |
TNavigate |
|
|
Improve this Doc
View Source
InsertInto<TTargetEntity>(String, Expression<Func<T1, TTargetEntity>>)
将查询转换为 INSERT INTO tableName SELECT ... FROM t 执行插入
Declaration
int InsertInto<TTargetEntity>(string tableName, Expression<Func<T1, TTargetEntity>> select)
where TTargetEntity : class
Parameters
Type |
Name |
Description |
System.String |
tableName |
指定插入的表名,若为 null 则使用 TTargetEntity 实体表名
|
System.Linq.Expressions.Expression<System.Func<T1, TTargetEntity>> |
select |
选择列
|
Returns
Type |
Description |
System.Int32 |
返回影响的行数
|
Type Parameters
Name |
Description |
TTargetEntity |
|
|
Improve this Doc
View Source
InsertIntoAsync<TTargetEntity>(String, Expression<Func<T1, TTargetEntity>>, CancellationToken)
Declaration
Task<int> InsertIntoAsync<TTargetEntity>(string tableName, Expression<Func<T1, TTargetEntity>> select, CancellationToken cancellationToken = default(CancellationToken))
where TTargetEntity : class
Parameters
Type |
Name |
Description |
System.String |
tableName |
|
System.Linq.Expressions.Expression<System.Func<T1, TTargetEntity>> |
select |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Int32> |
|
Type Parameters
Name |
Description |
TTargetEntity |
|
|
Improve this Doc
View Source
Max<TMember>(Expression<Func<T1, TMember>>)
Declaration
TMember Max<TMember>(Expression<Func<T1, TMember>> column)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
列
|
Returns
Type Parameters
Name |
Description |
TMember |
返回类型
|
|
Improve this Doc
View Source
MaxAsync<TMember>(Expression<Func<T1, TMember>>, CancellationToken)
Declaration
Task<TMember> MaxAsync<TMember>(Expression<Func<T1, TMember>> column, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<TMember> |
|
Type Parameters
|
Improve this Doc
View Source
Min<TMember>(Expression<Func<T1, TMember>>)
Declaration
TMember Min<TMember>(Expression<Func<T1, TMember>> column)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
列
|
Returns
Type Parameters
Name |
Description |
TMember |
返回类型
|
|
Improve this Doc
View Source
MinAsync<TMember>(Expression<Func<T1, TMember>>, CancellationToken)
Declaration
Task<TMember> MinAsync<TMember>(Expression<Func<T1, TMember>> column, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<TMember> |
|
Type Parameters
|
Improve this Doc
View Source
OrderBy<TMember>(Boolean, Expression<Func<T1, TMember>>)
按列排序,OrderBy(true, a => a.Time)
Declaration
ISelect<T1> OrderBy<TMember>(bool condition, Expression<Func<T1, TMember>> column)
Parameters
Type |
Name |
Description |
System.Boolean |
condition |
true 时生效
|
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
|
Returns
Type Parameters
|
Improve this Doc
View Source
OrderBy<TMember>(Expression<Func<T1, TMember>>)
按列排序,OrderBy(a => a.Time)
Declaration
ISelect<T1> OrderBy<TMember>(Expression<Func<T1, TMember>> column)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
|
Returns
Type Parameters
|
Improve this Doc
View Source
OrderByDescending<TMember>(Boolean, Expression<Func<T1, TMember>>)
按列倒向排序,OrderByDescending(true, a => a.Time)
Declaration
ISelect<T1> OrderByDescending<TMember>(bool condition, Expression<Func<T1, TMember>> column)
Parameters
Type |
Name |
Description |
System.Boolean |
condition |
true 时生效
|
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
列
|
Returns
Type Parameters
|
Improve this Doc
View Source
OrderByDescending<TMember>(Expression<Func<T1, TMember>>)
按列倒向排序,OrderByDescending(a => a.Time)
Declaration
ISelect<T1> OrderByDescending<TMember>(Expression<Func<T1, TMember>> column)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
列
|
Returns
Type Parameters
|
Improve this Doc
View Source
OrderByIf<TMember>(Boolean, Expression<Func<T1, TMember>>, Boolean)
按列排序,OrderByIf(true, a => a.Time)
Declaration
ISelect<T1> OrderByIf<TMember>(bool condition, Expression<Func<T1, TMember>> column, bool descending = false)
Parameters
Type |
Name |
Description |
System.Boolean |
condition |
true 时生效
|
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
|
System.Boolean |
descending |
true: DESC, false: ASC
|
Returns
Type Parameters
|
Improve this Doc
View Source
Sum<TMember>(Expression<Func<T1, TMember>>)
Declaration
decimal Sum<TMember>(Expression<Func<T1, TMember>> column)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
列
|
Returns
Type |
Description |
System.Decimal |
|
Type Parameters
Name |
Description |
TMember |
返回类型
|
|
Improve this Doc
View Source
SumAsync<TMember>(Expression<Func<T1, TMember>>, CancellationToken)
Declaration
Task<decimal> SumAsync<TMember>(Expression<Func<T1, TMember>> column, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TMember>> |
column |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Decimal> |
|
Type Parameters
|
Improve this Doc
View Source
ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, TReturn>>)
Declaration
TReturn ToAggregate<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, TReturn>> select)
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, TReturn>>, CancellationToken)
Declaration
Task<TReturn> ToAggregateAsync<TReturn>(Expression<Func<ISelectGroupingAggregate<T1>, TReturn>> select, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<ISelectGroupingAggregate<T1>, TReturn>> |
select |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<TReturn> |
|
Type Parameters
|
Improve this Doc
View Source
ToChunk<TReturn>(Expression<Func<T1, TReturn>>, Int32, Action<FetchCallbackArgs<List<TReturn>>>)
执行SQL查询,分块返回数据,可减少内存开销。比如读取10万条数据,每次返回100条处理。
Declaration
void ToChunk<TReturn>(Expression<Func<T1, TReturn>> select, int size, Action<FetchCallbackArgs<List<TReturn>>> done)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
选择列
|
System.Int32 |
size |
数据块的大小
|
System.Action<FetchCallbackArgs<System.Collections.Generic.List<TReturn>>> |
done |
处理数据块
|
Type Parameters
Name |
Description |
TReturn |
返回类型
|
|
Improve this Doc
View Source
ToDataTable<TReturn>(Expression<Func<T1, TReturn>>)
Declaration
DataTable ToDataTable<TReturn>(Expression<Func<T1, TReturn>> select)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
|
Returns
Type |
Description |
System.Data.DataTable |
|
Type Parameters
|
Improve this Doc
View Source
ToDataTableAsync<TReturn>(Expression<Func<T1, TReturn>>, CancellationToken)
Declaration
Task<DataTable> ToDataTableAsync<TReturn>(Expression<Func<T1, TReturn>> select, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Data.DataTable> |
|
Type Parameters
|
Improve this Doc
View Source
ToList<TDto>()
执行SQL查询,返回 TDto 映射的字段,记录不存在时返回 Count 为 0 的列表
Declaration
List<TDto> ToList<TDto>()
Returns
Type |
Description |
System.Collections.Generic.List<TDto> |
|
Type Parameters
|
Improve this Doc
View Source
ToList<TReturn>(Expression<Func<T1, TReturn>>)
执行SQL查询,返回指定字段的记录,记录不存在时返回 Count 为 0 的列表
Declaration
List<TReturn> ToList<TReturn>(Expression<Func<T1, TReturn>> select)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
选择列
|
Returns
Type |
Description |
System.Collections.Generic.List<TReturn> |
|
Type Parameters
Name |
Description |
TReturn |
返回类型
|
|
Improve this Doc
View Source
ToListAsync<TReturn>(Expression<Func<T1, TReturn>>, CancellationToken)
Declaration
Task<List<TReturn>> ToListAsync<TReturn>(Expression<Func<T1, TReturn>> select, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Collections.Generic.List<TReturn>> |
|
Type Parameters
|
Improve this Doc
View Source
ToListAsync<TDto>(CancellationToken)
Declaration
Task<List<TDto>> ToListAsync<TDto>(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Collections.Generic.List<TDto>> |
|
Type Parameters
|
Improve this Doc
View Source
ToOne<TDto>()
执行SQL查询,返回 TDto 映射的字段,记录不存在时返回 Dto 默认值
Declaration
Returns
Type Parameters
|
Improve this Doc
View Source
ToOne<TReturn>(Expression<Func<T1, TReturn>>)
执行SQL查询,返回指定字段的记录的第一条记录,记录不存在时返回 TReturn 默认值
Declaration
TReturn ToOne<TReturn>(Expression<Func<T1, TReturn>> select)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
选择列
|
Returns
Type Parameters
Name |
Description |
TReturn |
返回类型
|
|
Improve this Doc
View Source
ToOneAsync<TReturn>(Expression<Func<T1, TReturn>>, CancellationToken)
Declaration
Task<TReturn> ToOneAsync<TReturn>(Expression<Func<T1, TReturn>> select, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
|
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<TReturn> |
|
Type Parameters
|
Improve this Doc
View Source
ToOneAsync<TDto>(CancellationToken)
Declaration
Task<TDto> ToOneAsync<TDto>(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type |
Name |
Description |
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<TDto> |
|
Type Parameters
|
Improve this Doc
View Source
ToSql<TReturn>(Expression<Func<T1, TReturn>>, FieldAliasOptions)
Declaration
string ToSql<TReturn>(Expression<Func<T1, TReturn>> select, FieldAliasOptions fieldAlias = FieldAliasOptions.AsIndex)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TReturn>> |
select |
选择列
|
FieldAliasOptions |
fieldAlias |
字段别名
|
Returns
Type |
Description |
System.String |
|
Type Parameters
Name |
Description |
TReturn |
返回类型
|
|
Improve this Doc
View Source
UnionAll(ISelect<T1>[])
Declaration
ISelect<T1> UnionAll(params ISelect<T1>[] querys)
Parameters
Type |
Name |
Description |
ISelect<T1>[] |
querys |
|
Returns
|
Improve this Doc
View Source
Where(Expression<Func<T1, Boolean>>)
查询条件,Where(a => a.Id > 10),支持导航对象查询,Where(a => a.Author.Email == "2881099@qq.com")
Declaration
ISelect<T1> Where(Expression<Func<T1, bool>> exp)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, System.Boolean>> |
exp |
lambda表达式
|
Returns
|
Improve this Doc
View Source
Where<T2>(Expression<Func<T2, Boolean>>)
Declaration
ISelect<T1> Where<T2>(Expression<Func<T2, bool>> exp)
where T2 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T2, System.Boolean>> |
exp |
lambda表达式
|
Returns
Type Parameters
|
Improve this Doc
View Source
Where<T2>(Expression<Func<T1, T2, Boolean>>)
Declaration
ISelect<T1> Where<T2>(Expression<Func<T1, T2, bool>> exp)
where T2 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, T2, System.Boolean>> |
exp |
lambda表达式
|
Returns
Type Parameters
|
Improve this Doc
View Source
Where<T2, T3>(Expression<Func<T1, T2, T3, Boolean>>)
Declaration
ISelect<T1> Where<T2, T3>(Expression<Func<T1, T2, T3, bool>> exp)
where T2 : class where T3 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, T2, T3, System.Boolean>> |
exp |
lambda表达式
|
Returns
Type Parameters
|
Improve this Doc
View Source
Where<T2, T3, T4>(Expression<Func<T1, T2, T3, T4, Boolean>>)
Declaration
ISelect<T1> Where<T2, T3, T4>(Expression<Func<T1, T2, T3, T4, bool>> exp)
where T2 : class where T3 : class where T4 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, T2, T3, T4, System.Boolean>> |
exp |
lambda表达式
|
Returns
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
|
Improve this Doc
View Source
Where<T2, T3, T4, T5>(Expression<Func<T1, T2, T3, T4, T5, Boolean>>)
Declaration
ISelect<T1> Where<T2, T3, T4, T5>(Expression<Func<T1, T2, T3, T4, T5, bool>> exp)
where T2 : class where T3 : class where T4 : class where T5 : class
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, T2, T3, T4, T5, System.Boolean>> |
exp |
lambda表达式
|
Returns
Type Parameters
Name |
Description |
T2 |
|
T3 |
|
T4 |
|
T5 |
|
|
Improve this Doc
View Source
WhereCascade(Expression<Func<T1, Boolean>>)
多表查询时,该方法标记后,表达式条件将对所有表进行附加
例如:软删除、租户,每个表都给条件,挺麻烦的
fsql.Select<T1>().LeftJoin<T2>(...).Where<T2>((t1, t2 => t1.IsDeleted == false && t2.IsDeleted == false)
修改:fsql.Select<T1>().LeftJoin<T2>(...).WhereCascade(t1 => t1.IsDeleted == false)
当其中的实体可附加表达式才会进行,表越多时收益越大
Declaration
ISelect<T1> WhereCascade(Expression<Func<T1, bool>> exp)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, System.Boolean>> |
exp |
|
Returns
|
Improve this Doc
View Source
WhereDynamic(Object, Boolean)
传入动态条件,如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1}
Declaration
ISelect<T1> WhereDynamic(object dywhere, bool not = false)
Parameters
Type |
Name |
Description |
System.Object |
dywhere |
主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合
|
System.Boolean |
not |
是否标识为NOT
|
Returns
|
Improve this Doc
View Source
WhereIf(Boolean, Expression<Func<T1, Boolean>>)
查询条件,Where(true, a => a.Id > 10),支导航对象查询,Where(true, a => a.Author.Email == "2881099@qq.com")
Declaration
ISelect<T1> WhereIf(bool condition, Expression<Func<T1, bool>> exp)
Parameters
Type |
Name |
Description |
System.Boolean |
condition |
true 时生效
|
System.Linq.Expressions.Expression<System.Func<T1, System.Boolean>> |
exp |
lambda表达式
|
Returns
|
Improve this Doc
View Source
WithMemory(IEnumerable<T1>)
实现 select .. from ( select .. UNION ALL select .. ) a 这样的功能(基于内存数据)
Declaration
ISelect<T1> WithMemory(IEnumerable<T1> source)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T1> |
source |
内存数据
|
Returns
|
Improve this Doc
View Source
WithSql(String, Object)
实现 select .. from ( select ... from t ) a 这样的功能
使用 AsTable 方法也可以达到效果
示例:WithSql("select * from id=@id", new { id = 1 })
提示:parms 参数还可以传 Dictionary<string, object>
Declaration
ISelect<T1> WithSql(string sql, object parms = null)
Parameters
Type |
Name |
Description |
System.String |
sql |
SQL语句
|
System.Object |
parms |
参数
|
Returns
|
Improve this Doc
View Source
WithTempQuery<TDto>(Expression<Func<T1, TDto>>)
嵌套查询 select * from ( select ... from table ... ) a
Declaration
ISelect<TDto> WithTempQuery<TDto>(Expression<Func<T1, TDto>> selector)
Parameters
Type |
Name |
Description |
System.Linq.Expressions.Expression<System.Func<T1, TDto>> |
selector |
|
Returns
Type Parameters
Extension Methods
FreeSqlGlobalExtensions.OrderByRandom<TSelect, T1>(FreeSql.ISelect0<TSelect, T1>)