Skip to content

Commit 8029deb

Browse files
committed
Revert all other changes to compiled selectors and predicates.
1 parent 9a154af commit 8029deb

2 files changed

Lines changed: 42 additions & 107 deletions

File tree

SharpRepository.Repository/CompoundKeyRepositoryBase.cs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,9 @@ public IEnumerable<TResult> GetAll<TResult>(Expression<Func<T, TResult>> selecto
136136
public IEnumerable<TResult> GetAll<TResult>(Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions, IFetchStrategy<T> fetchStrategy)
137137
{
138138
if (selector == null) throw new ArgumentNullException("selector");
139-
var selectFunc = selector.Compile();
140139

141140
return _queryManager.ExecuteGetAll(
142-
() => GetAllQuery(queryOptions, fetchStrategy).Select(selectFunc).ToList(),
141+
() => GetAllQuery(queryOptions, fetchStrategy).Select(selector).ToList(),
143142
selector,
144143
queryOptions
145144
);
@@ -174,7 +173,6 @@ public T Get(params object[] keys)
174173
public TResult Get<TResult>(Expression<Func<T, TResult>> selector, params object[] keys)
175174
{
176175
if (selector == null) throw new ArgumentNullException("selector");
177-
var selectFunc = selector.Compile();
178176

179177
return _queryManager.ExecuteGet(
180178
() =>
@@ -184,7 +182,7 @@ public TResult Get<TResult>(Expression<Func<T, TResult>> selector, params object
184182
return default(TResult);
185183

186184
var results = new[] { result };
187-
return results.AsEnumerable().Select(selectFunc).First();
185+
return results.AsQueryable().Select(selector).First();
188186
},
189187
selector,
190188
keys
@@ -230,10 +228,9 @@ public IEnumerable<T> FindAll(ISpecification<T> criteria, IQueryOptions<T> query
230228
public IEnumerable<TResult> FindAll<TResult>(ISpecification<T> criteria, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null)
231229
{
232230
if (criteria == null) throw new ArgumentNullException("criteria");
233-
var selectFunc = selector.Compile();
234231

235232
return _queryManager.ExecuteFindAll(
236-
() => FindAllQuery(criteria, queryOptions).Select(selectFunc).ToList(),
233+
() => FindAllQuery(criteria, queryOptions).Select(selector).ToList(),
237234
criteria,
238235
selector,
239236
queryOptions
@@ -275,7 +272,6 @@ public TResult Find<TResult>(ISpecification<T> criteria, Expression<Func<T, TRes
275272
{
276273
if (criteria == null) throw new ArgumentNullException("criteria");
277274
if (selector == null) throw new ArgumentNullException("selector");
278-
var selectFunc = selector.Compile();
279275

280276
return _queryManager.ExecuteFind(
281277
() =>
@@ -285,7 +281,7 @@ public TResult Find<TResult>(ISpecification<T> criteria, Expression<Func<T, TRes
285281
return default(TResult);
286282

287283
var results = new[] { result };
288-
return results.AsEnumerable().Select(selectFunc).First();
284+
return results.AsQueryable().Select(selector).First();
289285
},
290286
criteria,
291287
selector,
@@ -719,10 +715,9 @@ public IEnumerable<TResult> GetAll<TResult>(Expression<Func<T, TResult>> selecto
719715
public IEnumerable<TResult> GetAll<TResult>(Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions, IFetchStrategy<T> fetchStrategy)
720716
{
721717
if (selector == null) throw new ArgumentNullException("selector");
722-
var selectFunc = selector.Compile();
723718

724719
return _queryManager.ExecuteGetAll(
725-
() => GetAllQuery(queryOptions, fetchStrategy).Select(selectFunc).ToList(),
720+
() => GetAllQuery(queryOptions, fetchStrategy).Select(selector).ToList(),
726721
selector,
727722
queryOptions
728723
);
@@ -758,7 +753,6 @@ public T Get(TKey key, TKey2 key2)
758753
public TResult Get<TResult>(TKey key, TKey2 key2, Expression<Func<T, TResult>> selector)
759754
{
760755
if (selector == null) throw new ArgumentNullException("selector");
761-
var selectFunc = selector.Compile();
762756

763757
return _queryManager.ExecuteGet(
764758
() =>
@@ -768,7 +762,7 @@ public TResult Get<TResult>(TKey key, TKey2 key2, Expression<Func<T, TResult>> s
768762
return default(TResult);
769763

770764
var results = new[] { result };
771-
return results.AsEnumerable().Select(selectFunc).First();
765+
return results.AsQueryable().Select(selector).First();
772766
},
773767
selector,
774768
key,
@@ -830,10 +824,9 @@ public IEnumerable<T> FindAll(ISpecification<T> criteria, IQueryOptions<T> query
830824
public IEnumerable<TResult> FindAll<TResult>(ISpecification<T> criteria, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null)
831825
{
832826
if (criteria == null) throw new ArgumentNullException("criteria");
833-
var selectFunc = selector.Compile();
834827

835828
return _queryManager.ExecuteFindAll(
836-
() => FindAllQuery(criteria, queryOptions).Select(selectFunc).ToList(),
829+
() => FindAllQuery(criteria, queryOptions).Select(selector).ToList(),
837830
criteria,
838831
selector,
839832
queryOptions
@@ -875,7 +868,6 @@ public TResult Find<TResult>(ISpecification<T> criteria, Expression<Func<T, TRes
875868
{
876869
if (criteria == null) throw new ArgumentNullException("criteria");
877870
if (selector == null) throw new ArgumentNullException("selector");
878-
var selectFunc = selector.Compile();
879871

880872
return _queryManager.ExecuteFind(
881873
() =>
@@ -885,7 +877,7 @@ public TResult Find<TResult>(ISpecification<T> criteria, Expression<Func<T, TRes
885877
return default(TResult);
886878

887879
var results = new[] { result };
888-
return results.AsEnumerable().Select(selectFunc).First();
880+
return results.AsQueryable().Select(selector).First();
889881
},
890882
criteria,
891883
selector,
@@ -1317,10 +1309,9 @@ public IEnumerable<TResult> GetAll<TResult>(Expression<Func<T, TResult>> selecto
13171309
public IEnumerable<TResult> GetAll<TResult>(Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions, IFetchStrategy<T> fetchStrategy)
13181310
{
13191311
if (selector == null) throw new ArgumentNullException("selector");
1320-
var selectFunc = selector.Compile();
13211312

13221313
return _queryManager.ExecuteGetAll(
1323-
() => GetAllQuery(queryOptions, fetchStrategy).Select(selectFunc).ToList(),
1314+
() => GetAllQuery(queryOptions, fetchStrategy).Select(selector).ToList(),
13241315
selector,
13251316
queryOptions
13261317
);
@@ -1357,7 +1348,6 @@ public T Get(TKey key, TKey2 key2, TKey3 key3)
13571348
public TResult Get<TResult>(TKey key, TKey2 key2, TKey3 key3, Expression<Func<T, TResult>> selector)
13581349
{
13591350
if (selector == null) throw new ArgumentNullException("selector");
1360-
var selectFunc = selector.Compile();
13611351

13621352
return _queryManager.ExecuteGet(
13631353
() =>
@@ -1367,7 +1357,7 @@ public TResult Get<TResult>(TKey key, TKey2 key2, TKey3 key3, Expression<Func<T,
13671357
return default(TResult);
13681358

13691359
var results = new[] { result };
1370-
return results.AsEnumerable().Select(selectFunc).First();
1360+
return results.AsQueryable().Select(selector).First();
13711361
},
13721362
selector,
13731363
key,
@@ -1430,10 +1420,9 @@ public IEnumerable<T> FindAll(ISpecification<T> criteria, IQueryOptions<T> query
14301420
public IEnumerable<TResult> FindAll<TResult>(ISpecification<T> criteria, Expression<Func<T, TResult>> selector, IQueryOptions<T> queryOptions = null)
14311421
{
14321422
if (criteria == null) throw new ArgumentNullException("criteria");
1433-
var selectFunc = selector.Compile();
14341423

14351424
return _queryManager.ExecuteFindAll(
1436-
() => FindAllQuery(criteria, queryOptions).Select(selectFunc).ToList(),
1425+
() => FindAllQuery(criteria, queryOptions).Select(selector).ToList(),
14371426
criteria,
14381427
selector,
14391428
queryOptions
@@ -1475,7 +1464,6 @@ public TResult Find<TResult>(ISpecification<T> criteria, Expression<Func<T, TRes
14751464
{
14761465
if (criteria == null) throw new ArgumentNullException("criteria");
14771466
if (selector == null) throw new ArgumentNullException("selector");
1478-
var selectFunc = selector.Compile();
14791467

14801468
return _queryManager.ExecuteFind(
14811469
() =>
@@ -1485,7 +1473,7 @@ public TResult Find<TResult>(ISpecification<T> criteria, Expression<Func<T, TRes
14851473
return default(TResult);
14861474

14871475
var results = new[] { result };
1488-
return results.AsEnumerable().Select(selectFunc).First();
1476+
return results.AsQueryable().Select(selector).First();
14891477
},
14901478
criteria,
14911479
selector,

0 commit comments

Comments
 (0)