2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / System.Data.Linq / src / DbLinq / Data / Linq / Sugar / IDataMapper.cs
1 #region MIT license\r
2 // \r
3 // MIT license\r
4 //\r
5 // Copyright (c) 2007-2008 Jiri Moudry, Pascal Craponne\r
6 // \r
7 // Permission is hereby granted, free of charge, to any person obtaining a copy\r
8 // of this software and associated documentation files (the "Software"), to deal\r
9 // in the Software without restriction, including without limitation the rights\r
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
11 // copies of the Software, and to permit persons to whom the Software is\r
12 // furnished to do so, subject to the following conditions:\r
13 // \r
14 // The above copyright notice and this permission notice shall be included in\r
15 // all copies or substantial portions of the Software.\r
16 // \r
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
23 // THE SOFTWARE.\r
24 // \r
25 #endregion\r
26 \r
27 using System;\r
28 using System.Collections.Generic;\r
29 using System.Data.Linq.Mapping;\r
30 using System.Reflection;\r
31 \r
32 using DbLinq.Data.Linq.Sugar.Expressions;\r
33 \r
34 #if MONO_STRICT\r
35 using System.Data.Linq;\r
36 #else\r
37 using DbLinq.Data.Linq;\r
38 #endif\r
39 \r
40 namespace DbLinq.Data.Linq.Sugar\r
41 {\r
42     internal interface IDataMapper\r
43     {\r
44         /// <summary>\r
45         /// Returns a table given a type, or null if the type is not mapped\r
46         /// </summary>\r
47         /// <param name="tableType"></param>\r
48         /// <param name="dataContext"></param>\r
49         /// <returns></returns>\r
50         string GetTableName(Type tableType, DataContext dataContext);\r
51 \r
52         /// <summary>\r
53         /// Returns a column name, provided its table and memberInfo\r
54         /// </summary>\r
55         /// <param name="tableExpression"></param>\r
56         /// <param name="memberInfo"></param>\r
57         /// <param name="dataContext"></param>\r
58         /// <returns></returns>\r
59         string GetColumnName(TableExpression tableExpression, MemberInfo memberInfo, DataContext dataContext);\r
60 \r
61         /// <summary>\r
62         /// Returns a column name, provided its table type and memberInfo\r
63         /// </summary>\r
64         /// <param name="tableType"></param>\r
65         /// <param name="memberInfo"></param>\r
66         /// <param name="dataContext"></param>\r
67         /// <returns></returns>\r
68         string GetColumnName(Type tableType, MemberInfo memberInfo, DataContext dataContext);\r
69 \r
70         /// <summary>\r
71         /// Enumerates PKs\r
72         /// </summary>\r
73         /// <param name="tableExpression"></param>\r
74         /// <param name="dataContext"></param>\r
75         /// <returns></returns>\r
76         IList<MemberInfo> GetPrimaryKeys(TableExpression tableExpression, DataContext dataContext);\r
77 \r
78         /// <summary>\r
79         /// Enumerates PKs\r
80         /// </summary>\r
81         /// <param name="tableDescription"></param>\r
82         /// <returns></returns>\r
83         IList<MemberInfo> GetPrimaryKeys(MetaTable tableDescription);\r
84 \r
85         /// <summary>\r
86         /// Lists table mapped columns\r
87         /// </summary>\r
88         /// <param name="tableDescription"></param>\r
89         /// <returns></returns>\r
90         IList<MemberInfo> GetColumns(MetaTable tableDescription);\r
91 \r
92         /// <summary>\r
93         /// Returns child associations (EntitySets)\r
94         /// </summary>\r
95         /// <param name="type"></param>\r
96         /// <returns></returns>\r
97         IList<MemberInfo> GetEntitySetAssociations(Type type);\r
98 \r
99         /// <summary>\r
100         /// Returns parent associations (EntityRef)\r
101         /// </summary>\r
102         /// <param name="type"></param>\r
103         /// <returns></returns>\r
104         IList<MemberInfo> GetEntityRefAssociations(Type type);\r
105 \r
106         /// <summary>\r
107         /// Returns association definition, if any\r
108         /// </summary>\r
109         /// <param name="thisTableExpression">The table referenced by the assocation (the type holding the member)</param>\r
110         /// <param name="memberInfo">The memberInfo related to association</param>\r
111         /// <param name="otherType"></param>\r
112         /// <param name="otherKey">The keys in the associated table</param>\r
113         /// <param name="joinType"></param>\r
114         /// <param name="joinID"></param>\r
115         /// <param name="dataContext"></param>\r
116         /// <returns>ThisKey</returns>\r
117         IList<MemberInfo> GetAssociation(TableExpression thisTableExpression, MemberInfo memberInfo, Type otherType, out IList<MemberInfo> otherKey, out TableJoinType joinType, out string joinID, DataContext dataContext);\r
118     }\r
119 }\r