Fix in templates
This commit is contained in:
parent
ad760cc1db
commit
f46d20c1ea
|
@ -6,7 +6,6 @@
|
|||
/// <param name="skip">How many {propertyName} to skip.</param>
|
||||
/// <param name="take">How many {propertyName} to take. (Default = 50)</param>
|
||||
/// <param name="orderDir">Optional Order direction</param>
|
||||
/// <param name="where">Optional where predicate.</param>
|
||||
/// <param name="orderBy">Optional order by predicate.</param>
|
||||
/// <returns>A bool if there's at least one record found and the resulting array. </returns>
|
||||
public static (bool, {returnTypeFullName}[]) Get{entityTypeName}{listPropertyName}(this {contextFullName} dbContext, {primaryKeyFullName} {primaryKeyVarName},
|
||||
|
|
|
@ -12,19 +12,21 @@ public static (bool, {returnTypeFullName}[]) Get{propertyName}(this {contextFull
|
|||
Expression <Func<{returnTypeFullName}, bool> > where = null,
|
||||
Expression <Func<{returnTypeFullName}, object> > orderBy = null)
|
||||
{
|
||||
if (take > 200) take = 200;
|
||||
|
||||
var query = dbContext
|
||||
.{propertyName}
|
||||
.Select(x => new {returnTypeFullName}(x));
|
||||
.Skip(skip)
|
||||
.Take(take);
|
||||
|
||||
// limit take by 200 records
|
||||
if (take > 200) take = 200;
|
||||
query.Skip(skip).Take(take);
|
||||
if (where != null) query = query.Where(where);
|
||||
|
||||
if (where != null) query.Where(where);
|
||||
if(orderBy != null)
|
||||
{
|
||||
if (orderDir == 1) query.OrderBy(orderBy);
|
||||
else query.OrderByDescending(orderBy);
|
||||
if (orderDir == 1) query = query.OrderBy(orderBy);
|
||||
else query = query.OrderByDescending(orderBy);
|
||||
}
|
||||
|
||||
return (query.Any(), query.ToArray());
|
||||
}
|
Loading…
Reference in New Issue