-
Notifications
You must be signed in to change notification settings - Fork 2
/
IDaJoinableLayer.cs
73 lines (69 loc) · 4.15 KB
/
IDaJoinableLayer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) 2004-2010 Azavea, Inc.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
using Azavea.Open.DAO.Criteria.Joins;
namespace Azavea.Open.DAO
{
/// <summary>
/// If the layer supports joins natively (such as SQL statements in the database)
/// it will implement this interface.
///
/// NOTE on transactions: The methods on the interface accept transactions,
/// but if your data source does not support transactions (or you have not
/// yet implemented support), you may ignore that parameter as long as your
/// equivilent IConnectionDescriptor is not an ITransactionalConnectionDescriptor.
/// </summary>
public interface IDaJoinableLayer
{
/// <summary>
/// This returns whether or not this layer can perform the requested
/// join natively. This lets a layer that can have native joins determine
/// whether this particular join is able to be done natively.
/// </summary>
/// <typeparam name="R">The type of object returned by the other DAO.</typeparam>
/// <param name="crit">The criteria specifying the requested join.</param>
/// <param name="rightConn">The connection info for the other DAO we're joining with.</param>
/// <param name="rightMapping">Class mapping for the right table we would be querying against.</param>
/// <returns>True if we can perform the join natively, false if we cannot.</returns>
bool CanJoin<R>(DaoJoinCriteria crit, IConnectionDescriptor rightConn, ClassMapping rightMapping) where R : new();
/// <summary>
/// This is not guaranteed to succeed unless CanJoin(crit, rightDao) returns true.
/// </summary>
/// <param name="crit">The criteria specifying the requested join.</param>
/// <param name="leftMapping">Class mapping for the left table we're querying against.</param>
/// <param name="rightMapping">Class mapping for the right table we're querying against.</param>
IDaJoinQuery CreateJoinQuery(DaoJoinCriteria crit, ClassMapping leftMapping,
ClassMapping rightMapping);
/// <summary>
/// This performs a count instead of an actual query. Depending on the data access layer
/// implementation, this may or may not be significantly faster than actually executing
/// the normal query and seeing how many results you get back. Generally it should be
/// faster.
/// </summary>
/// <param name="transaction">The transaction to do this as part of. May be null.</param>
/// <param name="crit">The criteria specifying the requested join.</param>
/// <param name="leftMapping">Class mapping for the left table we're querying against.</param>
/// <param name="rightMapping">Class mapping for the right table we're querying against.</param>
/// <returns>The number of results that you would get if you ran the actual query.</returns>
int GetCount(ITransaction transaction, DaoJoinCriteria crit, ClassMapping leftMapping, ClassMapping rightMapping);
}
}