/// /// Gets {listPropertyName} in {entityTypeName}. /// /// The database context. /// The {entityTypeName} key to get /// How many {propertyName} to skip. /// How many {propertyName} to take. (Default = 50) /// Optional Order direction /// Optional order by predicate. /// A bool if there's at least one record found and the resulting array. public static (bool, {returnTypeFullName}[]) Get{entityTypeName}{listPropertyName}(this {contextFullName} dbContext, {primaryKeyFullName} {primaryKeyVarName}, int skip = 0, int take = 50, int orderDir = 1, Expression> orderBy = null) { var {entityObjectVarName} = dbContext.{propertyName}.FirstOrDefault(d => d.{primaryKeyPropertyName} == {primaryKeyVarName}); if ({entityObjectVarName} == null) return (false, null); var currentTake = take; if (take > 200) currentTake = 200; var query = dbContext .{propertyName} .Where(data => data.{primaryKeyPropertyName} == {primaryKeyVarName}) .SelectMany(o => o.{listPropertyName}) .Select(x => new {returnTypeFullName}(x)) .Skip(skip) .Take(currentTake); if(orderBy != null) query = orderDir == 1 ? query.OrderBy(orderBy) : query.OrderByDescending(orderBy); return (query.Any(), query.ToArray()); }