|
@@ -5,6 +5,7 @@ using System.Linq;
|
5
|
5
|
using System.Linq.Expressions;
|
6
|
6
|
using iiie.Logs.DataAccess;
|
7
|
7
|
using iiie.Logs.DBO;
|
|
8
|
+using iiie.WebApiUtils.DBO;
|
8
|
9
|
|
9
|
10
|
namespace iiie.WebApiUtils.BusinessManager
|
10
|
11
|
{
|
|
@@ -134,13 +135,19 @@ namespace iiie.WebApiUtils.BusinessManager
|
134
|
135
|
/// <param name="page">The page numeber (0 based)</param>
|
135
|
136
|
/// <param name="perPage">The maximum number of items par page</param>
|
136
|
137
|
/// <returns>All matching objects</returns>
|
137
|
|
- public static OpResult<IEnumerable<TDboGet>> GetMultiple<TKey>(Expression<Func<TDbObject, bool>> predicate,
|
138
|
|
- Expression<Func<TDbObject, TKey>> orderBy, int page = 0,int perPage = Int32.MaxValue)
|
|
138
|
+ public static OpResult<DboGetMultiple<TDboGet>> GetMultiple<TKey>(Expression<Func<TDbObject, bool>> predicate,
|
|
139
|
+ Expression<Func<TDbObject, TKey>> orderBy, int page = 0, int perPage = Int32.MaxValue)
|
139
|
140
|
{
|
140
|
141
|
return Execute((db, table) =>
|
141
|
142
|
{
|
142
|
|
- var results = table.OrderBy(orderBy).Where(predicate).Skip(page * perPage).Take(perPage).ToList();
|
143
|
|
- return OpResult<IEnumerable<TDboGet>>.Ok(results.Select(DbToDboGetStatic));
|
|
143
|
+ var count = table.Count(predicate);
|
|
144
|
+ var results = table.OrderBy(orderBy).Where(predicate).Skip(page * perPage).Take(perPage).Select(DbToDboGetStatic).ToList();
|
|
145
|
+ var result = new DboGetMultiple<TDboGet>
|
|
146
|
+ {
|
|
147
|
+ Count = count,
|
|
148
|
+ Data = results
|
|
149
|
+ };
|
|
150
|
+ return OpResult<DboGetMultiple<TDboGet>>.Ok(result);
|
144
|
151
|
});
|
145
|
152
|
}
|
146
|
153
|
|
|
@@ -152,7 +159,7 @@ namespace iiie.WebApiUtils.BusinessManager
|
152
|
159
|
/// <param name="orderBy">The order by function</param>
|
153
|
160
|
/// <param name="keys">The key names and values</param>
|
154
|
161
|
/// <returns>All matching objects</returns>
|
155
|
|
- public static OpResult<IEnumerable<TDboGet>> GetMultipleByKeys<TKey>(Expression<Func<TDbObject, TKey>> orderBy,
|
|
162
|
+ public static OpResult<DboGetMultiple<TDboGet>> GetMultipleByKeys<TKey>(Expression<Func<TDbObject, TKey>> orderBy,
|
156
|
163
|
int page = 0, int perPage = Int32.MaxValue, params KeyValuePair<string, object>[] keys)
|
157
|
164
|
{
|
158
|
165
|
return GetMultiple(GetExpression(keys), orderBy, page, perPage);
|