2 using System.Collections.Generic;
9 namespace Deveel.Data.Mapping {
27 if (configurations == null)
28 configurations =
new Dictionary<Type, ITypeMappingConfiguration>();
30 var type = typeof (T);
32 if (configuration == null) {
34 if (!configurations.TryGetValue(type, out config)) {
36 configurations[type] = configuration;
41 configurations[type] = configuration;
49 if (configurations != null) {
50 foreach (var configuration
in configurations.Values) {
51 var mapping = CreateTypeMapping(model, configuration);
64 if (
String.IsNullOrEmpty(tableName))
67 if (TableNameConvention != null)
68 tableName = TableNameConvention.FormatName(tableName);
74 var tableName = GetTableName(configuration);
77 foreach (var pair
in configuration.Members) {
78 var member = pair.Value;
79 var memberMapping = MapMember(mapping, member);
80 mapping.AddMember(memberMapping);
88 var sqlType = FormSqlType(configuration);
93 var columnName = GetColumnName(configuration);
94 return new MemberMapping(mapping, configuration.
Member, columnName, sqlType, notNull, primary, unique, uniqueKey);
99 if (
String.IsNullOrEmpty(columnName))
100 columnName = configuration.
Member.Name;
102 if (ColumnNameConvention != null)
103 columnName = ColumnNameConvention.FormatName(columnName);
111 sqlType = DiscoverSqlType(configuration.
Member);
113 var meta =
new List<DataTypeMeta>();
114 if (configuration.
Size != null)
123 var memberType = TypeHelper.GetMemberType(member);
124 if (memberType == typeof(
bool))
126 if (memberType == typeof(byte))
128 if (memberType == typeof(
short))
130 if (memberType == typeof(
int))
132 if (memberType == typeof (
long))
135 if (memberType == typeof(
string))
138 throw new NotSupportedException();
A long string in the system.
ColumnConstraints ColumnConstraints
string GetTableName(ITypeMappingConfiguration configuration)
SqlTypeCode DiscoverSqlType(MemberInfo member)
MemberMapping MapMember(TypeMapping mapping, IMemberMappingConfiguration configuration)
bool IsUniqueKey(string memberName)
MappingModel CreateModel()
Defines the properties of a specific SQL Type and handles the values compatible.
string GetColumnName(IMemberMappingConfiguration configuration)
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Dictionary< Type, ITypeMappingConfiguration > configurations
TypeMapping CreateTypeMapping(MappingModel model, ITypeMappingConfiguration configuration)
static SqlType Resolve(SqlTypeCode typeCode)
static RuledNamingConvention SqlNaming
SqlType FormSqlType(IMemberMappingConfiguration configuration)