Skip to content

Commit de41447

Browse files
committed
added compound key
1 parent 3132ae9 commit de41447

12 files changed

Lines changed: 464 additions & 43 deletions
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq.Expressions;
4+
5+
namespace SharpRepository.Repository.Aspects
6+
{
7+
public class CompoundKeyRepositoryGetContext<T, TKey, TKey2> : CompoundKeyRepositoryGetContext<T, TKey, TKey2, T> where T : class
8+
{
9+
public CompoundKeyRepositoryGetContext(ICompoundKeyRepository<T, TKey, TKey2> repository, TKey id, TKey2 id2) : base(repository, id, id2)
10+
{
11+
}
12+
}
13+
14+
public class CompoundKeyRepositoryGetContext<T> : CompoundKeyRepositoryGetContext<T, T> where T : class
15+
{
16+
public CompoundKeyRepositoryGetContext(ICompoundKeyRepository<T> repository, IEnumerable<object> ids) : base(repository, ids)
17+
{
18+
}
19+
}
20+
21+
public class CompoundKeyRepositoryGetContext<T, TKey, TKey2, TResult> : RepositoryActionContext<T, TKey, TKey2> where T : class
22+
{
23+
public CompoundKeyRepositoryGetContext(ICompoundKeyRepository<T, TKey, TKey2> repository, TKey id, TKey2 id2, Expression<Func<T, TResult>> selector = null)
24+
: base(repository)
25+
{
26+
Id = id;
27+
Id2 = id2;
28+
Selector = selector;
29+
}
30+
31+
public TKey Id { get; set; }
32+
public TKey2 Id2 { get; set; }
33+
public TResult Result { get; set; }
34+
35+
public bool HasResult
36+
{
37+
get { return Result != null && !Result.Equals(default(TResult)); }
38+
}
39+
40+
public Expression<Func<T, TResult>> Selector { get; set; }
41+
}
42+
43+
public class CompoundKeyRepositoryGetContext<T, TResult> : RepositoryActionContext<T> where T : class
44+
{
45+
public CompoundKeyRepositoryGetContext(ICompoundKeyRepository<T> repository, IEnumerable<object> ids, Expression<Func<T, TResult>> selector = null)
46+
: base(repository)
47+
{
48+
Ids = ids;
49+
Selector = selector;
50+
}
51+
52+
public IEnumerable<object> Ids { get; set; }
53+
public TResult Result { get; set; }
54+
55+
public bool HasResult
56+
{
57+
get { return Result != null && !Result.Equals(default(TResult)); }
58+
}
59+
60+
public Expression<Func<T, TResult>> Selector { get; set; }
61+
}
62+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Linq.Expressions;
3+
using SharpRepository.Repository.Queries;
4+
using SharpRepository.Repository.Specifications;
5+
6+
namespace SharpRepository.Repository.Aspects
7+
{
8+
public abstract class CompoundKeyRepositoryQueryContext<T, TKey, TKey2> : CompoundKeyRepositoryQueryContext<T, TKey, TKey2, T> where T : class
9+
{
10+
protected CompoundKeyRepositoryQueryContext(ICompoundKeyRepository<T, TKey, TKey2> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions)
11+
: base(repository, specification, queryOptions)
12+
{
13+
}
14+
}
15+
16+
public abstract class CompoundKeyRepositoryQueryContext<T> : CompoundKeyRepositoryQueryContext<T, T> where T : class
17+
{
18+
protected CompoundKeyRepositoryQueryContext(ICompoundKeyRepository<T> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions)
19+
: base(repository, specification, queryOptions)
20+
{
21+
}
22+
}
23+
24+
public abstract class CompoundKeyRepositoryQueryContext<T, TKey, TKey2, TResult> : RepositoryActionContext<T, TKey, TKey2> where T : class
25+
{
26+
protected CompoundKeyRepositoryQueryContext(ICompoundKeyRepository<T, TKey, TKey2> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions, Expression<Func<T, TResult>> selector = null)
27+
: base(repository)
28+
{
29+
Specification = specification;
30+
QueryOptions = queryOptions;
31+
Selector = selector;
32+
}
33+
34+
public ISpecification<T> Specification { get; set; }
35+
public IQueryOptions<T> QueryOptions { get; set; }
36+
public virtual int NumberOfResults { get; internal set; }
37+
public Expression<Func<T, TResult>> Selector { get; set; }
38+
}
39+
40+
public abstract class CompoundKeyRepositoryQueryContext<T, TResult> : RepositoryActionContext<T> where T : class
41+
{
42+
protected CompoundKeyRepositoryQueryContext(ICompoundKeyRepository<T> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions, Expression<Func<T, TResult>> selector = null)
43+
: base(repository)
44+
{
45+
Specification = specification;
46+
QueryOptions = queryOptions;
47+
Selector = selector;
48+
}
49+
50+
public ISpecification<T> Specification { get; set; }
51+
public IQueryOptions<T> QueryOptions { get; set; }
52+
public virtual int NumberOfResults { get; internal set; }
53+
public Expression<Func<T, TResult>> Selector { get; set; }
54+
}
55+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Linq.Expressions;
5+
using SharpRepository.Repository.Queries;
6+
using SharpRepository.Repository.Specifications;
7+
8+
namespace SharpRepository.Repository.Aspects
9+
{
10+
public class CompoundKeyRepositoryQueryMultipleContext<T, TKey, TKey2> : CompoundKeyRepositoryQueryMultipleContext<T, TKey, TKey2, T> where T : class
11+
{
12+
public CompoundKeyRepositoryQueryMultipleContext(ICompoundKeyRepository<T, TKey, TKey2> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions)
13+
: base(repository, specification, queryOptions, null)
14+
{
15+
}
16+
}
17+
18+
public class CompoundKeyRepositoryQueryMultipleContext<T> : CompoundKeyRepositoryQueryMultipleContext<T, T> where T : class
19+
{
20+
public CompoundKeyRepositoryQueryMultipleContext(ICompoundKeyRepository<T> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions)
21+
: base(repository, specification, queryOptions, null)
22+
{
23+
}
24+
}
25+
26+
public class CompoundKeyRepositoryQueryMultipleContext<T, TKey, TKey2, TResult> : CompoundKeyRepositoryQueryContext<T, TKey, TKey2, TResult> where T : class
27+
{
28+
public CompoundKeyRepositoryQueryMultipleContext(ICompoundKeyRepository<T, TKey, TKey2> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions, Expression<Func<T, TResult>> selector = null)
29+
: base(repository, specification, queryOptions, selector)
30+
{
31+
}
32+
33+
public IEnumerable<TResult> Results { get; set; }
34+
public override int NumberOfResults
35+
{
36+
get { return Results == null ? 0 : Results.Count(); }
37+
}
38+
}
39+
40+
public class CompoundKeyRepositoryQueryMultipleContext<T, TResult> : CompoundKeyRepositoryQueryContext<T, TResult> where T : class
41+
{
42+
public CompoundKeyRepositoryQueryMultipleContext(ICompoundKeyRepository<T> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions, Expression<Func<T, TResult>> selector = null)
43+
: base(repository, specification, queryOptions, selector)
44+
{
45+
}
46+
47+
public IEnumerable<TResult> Results { get; set; }
48+
public override int NumberOfResults
49+
{
50+
get { return Results == null ? 0 : Results.Count(); }
51+
}
52+
}
53+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Linq.Expressions;
3+
using SharpRepository.Repository.Queries;
4+
using SharpRepository.Repository.Specifications;
5+
6+
namespace SharpRepository.Repository.Aspects
7+
{
8+
public class CompoundKeyRepositoryQuerySingleContext<T, TKey, TKey2> : CompoundKeyRepositoryQuerySingleContext<T, TKey, TKey2, T> where T : class
9+
{
10+
public CompoundKeyRepositoryQuerySingleContext(ICompoundKeyRepository<T, TKey, TKey2> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions)
11+
: base(repository, specification, queryOptions)
12+
{
13+
}
14+
}
15+
public class CompoundKeyRepositoryQuerySingleContext<T> : CompoundKeyRepositoryQuerySingleContext<T, T> where T : class
16+
{
17+
public CompoundKeyRepositoryQuerySingleContext(ICompoundKeyRepository<T> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions)
18+
: base(repository, specification, queryOptions)
19+
{
20+
}
21+
}
22+
public class CompoundKeyRepositoryQuerySingleContext<T, TKey, TKey2, TResult> : CompoundKeyRepositoryQueryContext<T, TKey, TKey2, TResult> where T : class
23+
{
24+
public CompoundKeyRepositoryQuerySingleContext(ICompoundKeyRepository<T, TKey, TKey2> repository, ISpecification<T> specification,
25+
IQueryOptions<T> queryOptions, Expression<Func<T, TResult>> selector = null)
26+
: base(repository, specification, queryOptions, selector)
27+
{
28+
}
29+
30+
public TResult Result { get; set; }
31+
32+
public bool HasResult
33+
{
34+
get { return NumberOfResults != 0; }
35+
}
36+
public override int NumberOfResults
37+
{
38+
get
39+
{
40+
return Result == null || Result.Equals(default(TResult)) ? 0 : 1;
41+
}
42+
}
43+
}
44+
public class CompoundKeyRepositoryQuerySingleContext<T, TResult> : CompoundKeyRepositoryQueryContext<T, TResult> where T : class
45+
{
46+
public CompoundKeyRepositoryQuerySingleContext(ICompoundKeyRepository<T> repository, ISpecification<T> specification,
47+
IQueryOptions<T> queryOptions, Expression<Func<T, TResult>> selector = null)
48+
: base(repository, specification, queryOptions, selector)
49+
{
50+
}
51+
52+
public TResult Result { get; set; }
53+
54+
public bool HasResult
55+
{
56+
get { return NumberOfResults != 0; }
57+
}
58+
public override int NumberOfResults
59+
{
60+
get
61+
{
62+
return Result == null || Result.Equals(default(TResult)) ? 0 : 1;
63+
}
64+
}
65+
}
66+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq.Expressions;
4+
5+
namespace SharpRepository.Repository.Aspects
6+
{
7+
public class CompoundTripleKeyRepositoryGetContext<T, TKey, TKey2, TKey3> : CompoundTripleKeyRepositoryGetContext<T, TKey, TKey2, TKey3, T> where T : class
8+
{
9+
public CompoundTripleKeyRepositoryGetContext(ICompoundKeyRepository<T, TKey, TKey2, TKey3> repository, TKey id, TKey2 id2, TKey3 id3) : base(repository, id, id2, id3)
10+
{
11+
}
12+
}
13+
14+
public class CompoundTripleKeyRepositoryGetContext<T, TKey, TKey2, TKey3, TResult> : RepositoryActionContext<T, TKey, TKey2, TKey3> where T : class
15+
{
16+
public CompoundTripleKeyRepositoryGetContext(ICompoundKeyRepository<T, TKey, TKey2, TKey3> repository, TKey id, TKey2 id2, TKey3 id3, Expression<Func<T, TResult>> selector = null)
17+
: base(repository)
18+
{
19+
Id = id;
20+
Id2 = id2;
21+
Id3 = id3;
22+
Selector = selector;
23+
}
24+
25+
public TKey Id { get; set; }
26+
public TKey2 Id2 { get; set; }
27+
public TKey3 Id3 { get; set; }
28+
public TResult Result { get; set; }
29+
30+
public bool HasResult
31+
{
32+
get { return Result != null && !Result.Equals(default(TResult)); }
33+
}
34+
35+
public Expression<Func<T, TResult>> Selector { get; set; }
36+
}
37+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Linq.Expressions;
3+
using SharpRepository.Repository.Queries;
4+
using SharpRepository.Repository.Specifications;
5+
6+
namespace SharpRepository.Repository.Aspects
7+
{
8+
public abstract class CompoundTripleKeyRepositoryQueryContext<T, TKey, TKey2, TKey3> : CompoundTripleKeyRepositoryQueryContext<T, TKey, TKey2, TKey3, T> where T : class
9+
{
10+
protected CompoundTripleKeyRepositoryQueryContext(ICompoundKeyRepository<T, TKey, TKey2, TKey3> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions)
11+
: base(repository, specification, queryOptions)
12+
{
13+
}
14+
}
15+
16+
public abstract class CompoundTripleKeyRepositoryQueryContext<T, TKey, TKey2, TKey3, TResult> : RepositoryActionContext<T, TKey, TKey2, TKey3> where T : class
17+
{
18+
protected CompoundTripleKeyRepositoryQueryContext(ICompoundKeyRepository<T, TKey, TKey2, TKey3> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions, Expression<Func<T, TResult>> selector = null)
19+
: base(repository)
20+
{
21+
Specification = specification;
22+
QueryOptions = queryOptions;
23+
Selector = selector;
24+
}
25+
26+
public ISpecification<T> Specification { get; set; }
27+
public IQueryOptions<T> QueryOptions { get; set; }
28+
public virtual int NumberOfResults { get; internal set; }
29+
public Expression<Func<T, TResult>> Selector { get; set; }
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Linq.Expressions;
5+
using SharpRepository.Repository.Queries;
6+
using SharpRepository.Repository.Specifications;
7+
8+
namespace SharpRepository.Repository.Aspects
9+
{
10+
public class CompoundTripleKeyRepositoryQueryMultipleContext<T, TKey, TKey2, TKey3> : CompoundTripleKeyRepositoryQueryMultipleContext<T, TKey, TKey2, TKey3, T> where T : class
11+
{
12+
public CompoundTripleKeyRepositoryQueryMultipleContext(ICompoundKeyRepository<T, TKey, TKey2, TKey3> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions)
13+
: base(repository, specification, queryOptions, null)
14+
{
15+
}
16+
}
17+
18+
public class CompoundTripleKeyRepositoryQueryMultipleContext<T, TKey, TKey2, TKey3, TResult> : CompoundTripleKeyRepositoryQueryContext<T, TKey, TKey2, TKey3, TResult> where T : class
19+
{
20+
public CompoundTripleKeyRepositoryQueryMultipleContext(ICompoundKeyRepository<T, TKey, TKey2, TKey3> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions, Expression<Func<T, TResult>> selector = null)
21+
: base(repository, specification, queryOptions, selector)
22+
{
23+
}
24+
25+
public IEnumerable<TResult> Results { get; set; }
26+
public override int NumberOfResults
27+
{
28+
get { return Results == null ? 0 : Results.Count(); }
29+
}
30+
}
31+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Linq.Expressions;
3+
using SharpRepository.Repository.Queries;
4+
using SharpRepository.Repository.Specifications;
5+
6+
namespace SharpRepository.Repository.Aspects
7+
{
8+
public class CompoundTripleKeyRepositoryQuerySingleContext<T, TKey, TKey2, TKey3> : CompoundTripleKeyRepositoryQuerySingleContext<T, TKey, TKey2, TKey3, T> where T : class
9+
{
10+
public CompoundTripleKeyRepositoryQuerySingleContext(ICompoundKeyRepository<T, TKey, TKey2, TKey3> repository, ISpecification<T> specification, IQueryOptions<T> queryOptions)
11+
: base(repository, specification, queryOptions)
12+
{
13+
}
14+
}
15+
16+
public class CompoundTripleKeyRepositoryQuerySingleContext<T, TKey, TKey2, TKey3, TResult> : CompoundTripleKeyRepositoryQueryContext<T, TKey, TKey2, TKey3, TResult> where T : class
17+
{
18+
public CompoundTripleKeyRepositoryQuerySingleContext(ICompoundKeyRepository<T, TKey, TKey2, TKey3> repository, ISpecification<T> specification,
19+
IQueryOptions<T> queryOptions, Expression<Func<T, TResult>> selector = null)
20+
: base(repository, specification, queryOptions, selector)
21+
{
22+
}
23+
24+
public TResult Result { get; set; }
25+
26+
public bool HasResult
27+
{
28+
get { return NumberOfResults != 0; }
29+
}
30+
public override int NumberOfResults
31+
{
32+
get
33+
{
34+
return Result == null || Result.Equals(default(TResult)) ? 0 : 1;
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)