public override void establish_context() { manyToOneARankedFirstToHolder = new ManyToOneMapping(); manyToOneARankedFirstToHolder.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(Holder))); manyToOneARankedFirstToHolder.Set(x => x.Name, Layer.Defaults, "ARankedFirstProperty"); manyToOneARankedFirstToHolder.ContainingEntityType = typeof(ARankedFirst); manyToOneARankedFirstToHolder.Member = new PropertyMember(typeof(ARankedFirst).GetProperty("ARankedFirstProperty")); manyToOneBRankedSecondToHolder = new ManyToOneMapping(); manyToOneBRankedSecondToHolder.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(Holder))); manyToOneBRankedSecondToHolder.Set(x => x.Name, Layer.Defaults, "BRankedSecondProperty"); manyToOneBRankedSecondToHolder.ContainingEntityType = typeof(BRankedSecond); manyToOneBRankedSecondToHolder.Member = new PropertyMember(typeof(BRankedSecond).GetProperty("BRankedSecondProperty")); var relationship = new OneToManyMapping(); relationship.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(BRankedSecond))); relationship.ContainingEntityType = typeof(Holder); collectionMappingToBRankedSecond = CollectionMapping.Bag(); collectionMappingToBRankedSecond.Set(x => x.ChildType, Layer.Defaults, typeof(BRankedSecond)); collectionMappingToBRankedSecond.Set(x => x.Name, Layer.Defaults, "ColectionOfBRankedSeconds"); collectionMappingToBRankedSecond.Set(x => x.Relationship, Layer.Defaults, relationship); collectionMappingToBRankedSecond.ContainingEntityType = typeof(Holder); visitor = new RelationshipPairingVisitor(A.Fake<PairBiDirectionalManyToManySidesDelegate>()); }
public override void Visit(CollectionMapping collectionMapping) { var writer = serviceLocator.GetWriter<CollectionMapping>(); var xml = writer.Write(collectionMapping); document.ImportAndAppendChild(xml); }
public override void ProcessCollection(CollectionMapping mapping) { if (mapping.Relationship is ManyToManyMapping) manyToManys.Add(mapping); if (mapping.Relationship is OneToManyMapping) oneToManys.Add(mapping); }
public override void establish_context() { var autoPersistenceModel = AutoMap.Source(new Types(), new AutomappingConfiguration()); var hibernateMappings = autoPersistenceModel.BuildMappings(); var classMapping = hibernateMappings.SelectMany(h => h.Classes).Single(c => c.Type == typeof(Parent)); collectionWithCorrespondingBackref = classMapping.Collections.Single(c => c.ChildType == typeof(ChildSecondType)); }
static void SetRelationship(Member property, ClassMappingBase classMap, CollectionMapping mapping) { var relationship = new OneToManyMapping { ContainingEntityType = classMap.Type }; relationship.Set(x => x.Class, Layer.Defaults, new TypeReference(property.PropertyType.GetGenericArguments()[0])); mapping.Set(x => x.Relationship, Layer.Defaults, relationship); }
private static void SetKey(Member property, ClassMappingBase classMap, CollectionMapping mapping) { var ColumnName = "Id_"+property.DeclaringType.Name; var ColumnMapping = new ColumnMapping(); ColumnMapping.Set(x => x.Name, Layer.Defaults, ColumnName); var Key = new KeyMapping {ContainingEntityType = classMap.Type}; Key.AddColumn(Layer.Defaults, ColumnMapping); mapping.Set(x => x.Key, Layer.Defaults, Key); }
protected void WriteBaseCollectionAttributes(XmlElement element, CollectionMapping mapping) { if (mapping.IsSpecified("Access")) element.WithAtt("access", mapping.Access); if (mapping.IsSpecified("BatchSize")) element.WithAtt("batch-size", mapping.BatchSize); if (mapping.IsSpecified("Cascade")) element.WithAtt("cascade", mapping.Cascade); if (mapping.IsSpecified("Check")) element.WithAtt("check", mapping.Check); if (mapping.IsSpecified("CollectionType") && mapping.CollectionType != TypeReference.Empty) element.WithAtt("collection-type", mapping.CollectionType); if (mapping.IsSpecified("Fetch")) element.WithAtt("fetch", mapping.Fetch); if (mapping.IsSpecified("Generic")) element.WithAtt("generic", mapping.Generic); if (mapping.IsSpecified("Inverse")) element.WithAtt("inverse", mapping.Inverse); if (mapping.IsSpecified("Lazy")) element.WithAtt("lazy", mapping.Lazy.ToString().ToLowerInvariant()); if (mapping.IsSpecified("Name")) element.WithAtt("name", mapping.Name); if (mapping.IsSpecified("OptimisticLock")) element.WithAtt("optimistic-lock", mapping.OptimisticLock); if (mapping.IsSpecified("Persister")) element.WithAtt("persister", mapping.Persister); if (mapping.IsSpecified("Schema")) element.WithAtt("schema", mapping.Schema); if (mapping.IsSpecified("TableName")) element.WithAtt("table", mapping.TableName); if (mapping.IsSpecified("Where")) element.WithAtt("where", mapping.Where); if (mapping.IsSpecified("Subselect")) element.WithAtt("subselect", mapping.Subselect); if (mapping.IsSpecified("Mutable")) element.WithAtt("mutable", mapping.Mutable); }
private void SetElement(Member property, ClassMappingBase classMap, CollectionMapping mapping) { var element = new ElementMapping { ContainingEntityType = classMap.Type, }; element.Set(x => x.Type, Layer.Defaults, new TypeReference(property.PropertyType.GetGenericArguments()[0])); var columnMapping = new ColumnMapping(); columnMapping.Set(x => x.Name, Layer.Defaults, cfg.SimpleTypeCollectionValueColumn(property)); element.AddColumn(Layer.Defaults, columnMapping); mapping.Set(x => x.Element, Layer.Defaults, element); }
void SetDefaultAccess(Member member, CollectionMapping mapping) { var resolvedAccess = MemberAccessResolver.Resolve(member); if (resolvedAccess != Access.Property && resolvedAccess != Access.Unset) { // if it's a property or unset then we'll just let NH deal with it, otherwise // set the access to be whatever we determined it might be mapping.Set(x => x.Access, Layer.Defaults, resolvedAccess.ToString()); } if (member.IsProperty && !member.CanWrite) mapping.Set(x => x.Access, Layer.Defaults, cfg.GetAccessStrategyForReadOnlyProperty(member).ToString()); }
static CollectionMapping FindAlternative(IEnumerable<CollectionMapping> rs, CollectionMapping current, CollectionMapping otherSide) { var alternative = rs .Where(x => self_referenced_relation_does_not_point_to_itself(x, current)) .Where(x => x.ContainingEntityType == current.ContainingEntityType) .Select(x => GetLikeness(x, otherSide)) .OrderBy(x => x.Differences) .FirstOrDefault(); if (alternative == null) return null; return alternative.Collection; }
public void SetKey(Member property, ClassMappingBase classMap, CollectionMapping mapping) { var columnName = property.DeclaringType.Name + "_id"; var key = new KeyMapping { ContainingEntityType = classMap.Type }; var columnMapping = new ColumnMapping(); columnMapping.Set(x => x.Name, Layer.Defaults, columnName); key.AddColumn(Layer.Defaults, columnMapping); mapping.Set(x => x.Key, Layer.Defaults, key); }
void SetDefaultAccess(Member member, CollectionMapping mapping) { var resolvedAccess = MemberAccessResolver.Resolve(member); if (resolvedAccess != Access.Property && resolvedAccess != Access.Unset) { mapping.Set(x => x.Access, Layer.Defaults, resolvedAccess.ToString()); } if (member.IsProperty && !member.CanWrite) { mapping.Set(x => x.Access, Layer.Defaults, _configuration.GetAccessStrategyForReadOnlyProperty(member).ToString()); } }
public override void ProcessCollection(CollectionMapping mapping) { if (!Enabled) return; var otherSide = mapping.OtherSide as CollectionMapping; if (otherSide == null) return; if (mapping.Inverse && otherSide.Inverse) { throw new ValidationException( string.Format("The relationship {0}.{1} to {2}.{3} has Inverse specified on both sides.", mapping.ContainingEntityType.Name, mapping.Name, otherSide.ContainingEntityType.Name, otherSide.Name), "Remove Inverse from one side of the relationship", mapping.ContainingEntityType); } }
private void ConfigureModel(Member member, CollectionMapping mapping, ClassMappingBase classMap, Type parentSide) { // TODO: Make the child type safer mapping.ContainingEntityType = classMap.Type; mapping.Set(x => x.Name, Layer.Defaults, member.Name); mapping.Set(x => x.Relationship, Layer.Defaults, CreateManyToMany(member, member.PropertyType.GetGenericArguments()[0], classMap.Type)); mapping.Set(x => x.ChildType, Layer.Defaults, member.PropertyType.GetGenericArguments()[0]); mapping.Member = member; SetDefaultAccess(member, mapping); SetKey(member, classMap, mapping); if (parentSide != member.DeclaringType) mapping.Set(x => x.Inverse, Layer.Defaults, true); }
public ColumnMapping Apply(CollectionMapping colectionMap, Lazy <Dictionary <Type, ClassMapping> > lazyTypeMap) { var keyName = GetKeyName(null, colectionMap.ContainingEntityType); if (typeof(ILocalizableCodeListLanguage).IsAssignableFrom(colectionMap.ChildType)) { keyName = "CodeListCode"; } var codeListAttr = colectionMap.ContainingEntityType.GetCustomAttribute <CodeListConfigurationAttribute>(false); var length = codeListAttr?.CodeLength ?? 20; var col = colectionMap.Key.Columns.First(); col.Set(o => o.Name, Layer.UserSupplied, keyName); col.Set(o => o.Length, Layer.UserSupplied, length); return(col); }
void SetDefaultAccess(Member member, CollectionMapping mapping) { var resolvedAccess = MemberAccessResolver.Resolve(member); if (resolvedAccess != Access.Property && resolvedAccess != Access.Unset) { // if it's a property or unset then we'll just let NH deal with it, otherwise // set the access to be whatever we determined it might be mapping.Set(x => x.Access, Layer.Defaults, resolvedAccess.ToString()); } if (member.IsProperty && !member.CanWrite) { mapping.Set(x => x.Access, Layer.Defaults, _cfg.GetAccessStrategyForReadOnlyProperty(member).ToString()); } }
public ActionResult CollectionMappingUpdate(FormCollection collection) { var s = collection; CollectionMapping upd = new CollectionMapping(); upd.Id = int.Parse(collection["Id"]); upd.Collection = collection["Collection"]; upd.LanguageCulture = collection["LanguageCulture"]; var updNew = _collectionMappingService.GetCollectionMappingById(upd.Id); updNew.LanguageCulture = upd.LanguageCulture; updNew.Collection = upd.Collection; _collectionMappingService.UpdateMapping(updNew); return(new NullJsonResult()); }
protected virtual void SerializeCollection <T>(CollectionMapping collectionMapping, T data, TSerializeState state) { var objectValue = AttemptGetValue(collectionMapping, data, state); if (objectValue == null) { return; } var collectionValue = (objectValue as IList); AddCountToState(state, collectionValue.Count); for (var i = 0; i < collectionValue.Count; i++) { var element = collectionValue[i]; SerializeCollectionElement(collectionMapping, element, state); } }
static CollectionMapping FindAlternative(IEnumerable <CollectionMapping> rs, CollectionMapping current, CollectionMapping otherSide) { var alternative = rs .Where(x => self_referenced_relation_does_not_point_to_itself(x, current)) .Where(x => x.ContainingEntityType == current.ContainingEntityType && x.ChildType == current.ChildType) .Select(x => GetLikeness(x, otherSide)) .OrderBy(x => x.Differences) .FirstOrDefault(); if (alternative == null) { return(null); } return(alternative.Collection); }
private void ConfigureModel(Member member, CollectionMapping mapping, ClassMappingBase classMap, Type parentSide) { // TODO: Make the child type safer mapping.ContainingEntityType = classMap.Type; mapping.Set(x => x.Name, Layer.Defaults, member.Name); mapping.Set(x => x.Relationship, Layer.Defaults, CreateManyToMany(member, member.PropertyType.GetGenericArguments()[0], classMap.Type)); mapping.Set(x => x.ChildType, Layer.Defaults, member.PropertyType.GetGenericArguments()[0]); mapping.Member = member; SetDefaultAccess(member, mapping); SetKey(member, classMap, mapping); if (parentSide != member.DeclaringType) { mapping.Set(x => x.Inverse, Layer.Defaults, true); } }
public override void ProcessCollection(CollectionMapping mapping) { if (!(mapping.Relationship is ManyToManyMapping)) return; if (mapping.OtherSide == null) { // uni-directional mapping.Set(x => x.TableName, Layer.Defaults, mapping.ChildType.Name + "To" + mapping.ContainingEntityType.Name); } else { var otherSide = (CollectionMapping)mapping.OtherSide; var tableName = mapping.TableName ?? otherSide.TableName ?? otherSide.Member.Name + "To" + mapping.Member.Name; mapping.Set(x => x.TableName, Layer.Defaults, tableName); otherSide.Set(x => x.TableName, Layer.Defaults, tableName); } }
public void Map(ClassMappingBase classMap, Member member) { if (member.DeclaringType != classMap.Type) { return; } var collectionType = CollectionTypeResolver.Resolve(member); var mapping = CollectionMapping.For(collectionType); mapping.ContainingEntityType = classMap.Type; mapping.Member = member; mapping.Set(x => x.Name, Layer.Defaults, member.Name); SetDefaultAccess(member, mapping); keys.SetKey(member, classMap, mapping); SetElement(member, classMap, mapping); classMap.AddCollection(mapping); }
public override void ProcessCollection(CollectionMapping mapping) { if (!Enabled) { return; } var otherSide = mapping.OtherSide as CollectionMapping; if (otherSide == null) { return; } if (mapping.Inverse && otherSide.Inverse) { throw new ValidationException( string.Format("The relationship {0}.{1} to {2}.{3} has Inverse specified on both sides.", mapping.ContainingEntityType.Name, mapping.Name, otherSide.ContainingEntityType.Name, otherSide.Name), "Remove Inverse from one side of the relationship", mapping.ContainingEntityType); } }
public void Map(ClassMappingBase classMap, Member member) { if (member.DeclaringType != classMap.Type) { return; } var collectionType = CollectionTypeResolver.Resolve(member); var mapping = CollectionMapping.For(collectionType); mapping.ContainingEntityType = classMap.Type; mapping.Member = member; mapping.Set(x => x.Name, Layer.Defaults, member.Name); mapping.Set(x => x.ChildType, Layer.Defaults, member.PropertyType.GetGenericArguments()[0]); SetDefaultAccess(member, mapping); SetRelationship(member, classMap, mapping); keys.SetKey(member, classMap, mapping); classMap.AddCollection(mapping); }
protected override void SerializeCollection <T>(CollectionMapping collectionMapping, T data, JToken state) { var objectValue = AttemptGetValue(collectionMapping, data, state); if (objectValue == null) { return; } var collectionValue = (objectValue as IList); var jsonArray = new JArray(); state.Replace(jsonArray); for (var i = 0; i < collectionValue.Count; i++) { var element = collectionValue[i]; var jsonObject = new JObject(); jsonArray.Add(jsonObject); SerializeCollectionElement(collectionMapping, element, jsonObject); } }
public override void ProcessCollection(CollectionMapping mapping) { if (!(mapping.Relationship is ManyToManyMapping)) { return; } if (mapping.OtherSide == null) { // uni-directional mapping.Set(x => x.TableName, Layer.Defaults, mapping.ChildType.Name + "To" + mapping.ContainingEntityType.Name); } else { var otherSide = (CollectionMapping)mapping.OtherSide; var tableName = mapping.TableName ?? otherSide.TableName ?? otherSide.Member.Name + "To" + mapping.Member.Name; mapping.Set(x => x.TableName, Layer.Defaults, tableName); otherSide.Set(x => x.TableName, Layer.Defaults, tableName); } }
protected virtual object DeserializeCollectionElement(CollectionMapping mapping, TDeserializeState state) { if (IsObjectNull(state)) { return(null); } if (mapping.IsElementDynamicType) { return(DeserializeDynamicTypeData(state)); } if (mapping.InternalMappings.Count > 0) { var elementInstance = TypeCreator.Instantiate(mapping.CollectionType); Deserialize(mapping.InternalMappings, elementInstance, state); return(elementInstance); } return(DeserializePrimitive(mapping.CollectionType, state)); }
protected virtual void SerializeCollectionElement <T>(CollectionMapping collectionMapping, T element, TSerializeState state) { if (element == null) { HandleNullObject(state); return; } if (collectionMapping.IsElementDynamicType) { SerializeDynamicTypeData(element, state); return; } if (collectionMapping.InternalMappings.Count > 0) { Serialize(collectionMapping.InternalMappings, element, state); return; } SerializePrimitive(element, collectionMapping.CollectionType, state); }
void UpdateBox(ComboBox box, string category, List <Type> types) { var mapping = Options.CollectionMappings.FirstOrDefault(m => m.Category == category); if (mapping == null) { mapping = new CollectionMapping { Category = category }; Options.CollectionMappings.Add(mapping); Modified = true; } var current = types [box.Active]; if (mapping.TypeName != current.FullName) { mapping.TypeName = current.FullName; Modified = true; } }
private static IEntityMapping BuildMapping <TEntity>(this ICollection <ITermMappingProvider> mappingProviders, out IPropertyMapping firstPropertyMapping) { firstPropertyMapping = null; var entityMapping = new MergingEntityMapping(typeof(TEntity)); foreach (var mappingProvider in mappingProviders) { mappingProvider.Accept(MappingVisitors); var entityMappingProvider = mappingProvider as IEntityMappingProvider; if (entityMappingProvider != null) { entityMapping.Classes.Add(new StatementMapping(entityMappingProvider.GetGraph(QIriMappings), entityMappingProvider.GetTerm(QIriMappings))); continue; } var propertyMappingProvider = mappingProvider as IPropertyMappingProvider; if (propertyMappingProvider == null) { continue; } ILiteralConverter valueConverter = null; if (propertyMappingProvider.ValueConverterType != null) { valueConverter = ConverterProvider.FindConverter(propertyMappingProvider.ValueConverterType); } var collectionMappingProvider = mappingProvider as ICollectionMappingProvider; var propertyMapping = (collectionMappingProvider != null ? CollectionMapping.CreateFrom(entityMapping, collectionMappingProvider, valueConverter, QIriMappings) : PropertyMapping.CreateFrom(entityMapping, propertyMappingProvider, valueConverter, QIriMappings)); entityMapping.Properties.Add(propertyMapping); if (firstPropertyMapping == null) { firstPropertyMapping = propertyMapping; } } return(entityMapping); }
public override ReferenceComponentMapping create_mapping() { var mapping = new ReferenceComponentMapping(ComponentType.Component, new DummyPropertyInfo("name", typeof(Target)).ToMember(), typeof(Target), typeof(Target), null); mapping.AssociateExternalMapping(new ExternalComponentMapping(ComponentType.Component)); mapping.Access = "access"; mapping.ContainingEntityType = typeof(Target); mapping.Insert = true; mapping.Name = "name"; mapping.OptimisticLock = true; mapping.Parent = new ParentMapping(); mapping.Unique = true; mapping.Update = true; mapping.AddAny(new AnyMapping()); mapping.AddCollection(CollectionMapping.Bag()); mapping.AddComponent(new ComponentMapping(ComponentType.Component)); mapping.AddOneToOne(new OneToOneMapping()); mapping.AddProperty(new PropertyMapping()); mapping.AddReference(new ManyToOneMapping()); return(mapping); }
public override void establish_context() { parentMapping = new ParentMapping(); externalComponentMapping = new ExternalComponentMapping(ComponentType.Component); externalComponentMapping.Set(x => x.Access, Layer.Defaults, "access"); externalComponentMapping.Set(x => x.Insert, Layer.Defaults, true); externalComponentMapping.Set(x => x.Lazy, Layer.Defaults, true); externalComponentMapping.Set(x => x.OptimisticLock, Layer.Defaults, true); externalComponentMapping.Set(x => x.Parent, Layer.Defaults, parentMapping); externalComponentMapping.Set(x => x.Unique, Layer.Defaults, true); externalComponentMapping.Set(x => x.Update, Layer.Defaults, true); externalComponentMapping.AddAny(new AnyMapping()); externalComponentMapping.AddCollection(CollectionMapping.Bag()); externalComponentMapping.AddComponent(new ComponentMapping(ComponentType.Component)); externalComponentMapping.AddFilter(new FilterMapping()); externalComponentMapping.AddOneToOne(new OneToOneMapping()); externalComponentMapping.AddProperty(new PropertyMapping()); externalComponentMapping.AddReference(new ManyToOneMapping()); memberProperty = new DummyPropertyInfo("Component", typeof(Target)).ToMember(); referenceComponentMapping = new ReferenceComponentMapping(ComponentType.Component, memberProperty, typeof(ComponentTarget), typeof(Target), "column-prefix"); }
public void Map(ClassMappingBase classMap, Member member) { var collectionType = CollectionTypeResolver.Resolve(member); var mapping = CollectionMapping.For(collectionType); mapping.ContainingEntityType = classMap.Type; mapping.Member = member; mapping.Set(x => x.Name, Layer.Defaults, member.Name); mapping.Set(x => x.ChildType, Layer.Defaults, member.PropertyType.GetGenericArguments()[0]); SetDefaultAccess(member, mapping); SetRelationship(member, classMap, mapping); _keys.SetKey(member, classMap, mapping); var column = mapping.Key.Columns.FirstOrDefault(); if (column != null) { column.Set(x => x.Name, Layer.UserSupplied, "CodeListId"); } classMap.AddOrReplaceCollection(mapping); }
public virtual CollectionMapping CreateCollectionMappingFor(PropertyInfo propertyInfo, string scope) { var propertyType = propertyInfo.PropertyType; var collectionType = TypeAnalyzer.GetElementType(propertyType); var collectionMapping = new CollectionMapping { LocalName = propertyInfo.Name, ScopedName = scope, CollectionType = collectionType, Type = propertyInfo.PropertyType, GetValue = (x) => propertyInfo.GetValue(x, null) as IList, SetValue = (x, v) => propertyInfo.SetValue(x, v, null), IsArray = propertyType.IsArray, IsElementDynamicType = TypeAnalyzer.IsDynamicType(collectionType) }; var collectionMappingTypes = GetMappingsFromType(collectionType, scope); collectionMapping.InternalMappings.AddRange(collectionMappingTypes); return(collectionMapping); }
public override SubclassMapping create_mapping() { var mapping = new SubclassMapping(SubclassType.JoinedSubclass) { Abstract = true, BatchSize = 10, Check = "check", DynamicInsert = true, DynamicUpdate = true, EntityName = "entity-name", Lazy = true, Name = "name", Persister = new TypeReference(typeof(Target)), Proxy = "proxy", Schema = "schema", SelectBeforeUpdate = true, Subselect = "subselect", TableName = "table", Type = typeof(Target), Extends = typeof(Target), Key = new KeyMapping() }; mapping.AddAny(new AnyMapping()); mapping.AddCollection(CollectionMapping.Bag()); mapping.AddComponent(new ComponentMapping(ComponentType.Component)); mapping.AddFilter(new FilterMapping()); mapping.AddJoin(new JoinMapping()); mapping.AddOneToOne(new OneToOneMapping()); mapping.AddProperty(new PropertyMapping()); mapping.AddReference(new ManyToOneMapping()); mapping.AddStoredProcedure(new StoredProcedureMapping()); mapping.AddSubclass(new SubclassMapping(SubclassType.Subclass)); return(mapping); }
public CollectionInspector(CollectionMapping mapping) { this.mapping = mapping; propertyMappings.Map(x => x.LazyLoad, x => x.Lazy); }
public virtual void Visit(CollectionMapping collectionMapping) { }
static CollectionMapping GetCollection(Member property) { var collectionType = CollectionTypeResolver.Resolve(property); return(CollectionMapping.For(collectionType)); }
public OneToManyCollectionInstance(CollectionMapping mapping) : base(mapping) { nextBool = true; this.mapping = mapping; }
static CollectionMapping PairExactMatches(IEnumerable<CollectionMapping> rs, CollectionMapping current, IEnumerable<CollectionMapping> potentialOtherSides) { var otherSide = potentialOtherSides.Single(); // got the other side of the relationship // lets make sure that the side that we're on now (mapping!) // is actually the relationship we want var mapping = FindAlternative(rs, current, otherSide) ?? current; mapping.OtherSide = otherSide; otherSide.OtherSide = mapping; return mapping; }
static bool self_referenced_relation_does_not_point_to_itself(CollectionMapping left, CollectionMapping right) { return left.ChildType == left.ContainingEntityType && right.ChildType == right.ContainingEntityType && left != right; }
static bool self_referenced_relation_does_not_point_to_itself(CollectionMapping left, CollectionMapping right) { return(left.ChildType == left.ContainingEntityType && right.ChildType == right.ContainingEntityType && left != right); }
static bool both_collections_point_to_each_others_types(CollectionMapping left, CollectionMapping right) { return(left.ContainingEntityType == right.ChildType && left.ChildType == right.ContainingEntityType); }
public override void Visit(CollectionMapping collectionMapping) { collectionMapping.AcceptVisitor(this); }
public void AddCollection(CollectionMapping collection) { mergedComponent.AddCollection(collection); }
/// <summary> /// Use a map collection /// </summary> /// <typeparam name="TIndex">Index type</typeparam> /// <param name="indexColumnName">Index column name</param> public T AsMap <TIndex>(string indexColumnName) { collectionBuilder = attrs => CollectionMapping.Map(attrs); AsIndexedCollection <TIndex>(indexColumnName, null); return((T)this); }
static LikenessContainer GetLikeness(CollectionMapping currentMapping, CollectionMapping mapping) { var currentMemberName = GetMemberName(currentMapping.Member); var mappingMemberName = GetMemberName(mapping.Member); return new LikenessContainer { Collection = currentMapping, CurrentMemberName = currentMemberName, MappingMemberName = mappingMemberName, Differences = StringLikeness.EditDistance(currentMemberName, mappingMemberName) }; }
static CollectionMapping PairFuzzyMatches(IEnumerable <CollectionMapping> rs, CollectionMapping current, IEnumerable <CollectionMapping> potentialOtherSides) { // no exact matches found, drop down to a levenshtein distance var mapping = current; var likenesses = potentialOtherSides .Select(x => GetLikeness(x, current)) .Where(likeness_within_threshold) .OrderBy(x => x.Differences); var first = likenesses.FirstOrDefault(); if (first == null || AnyHaveSameLikeness(likenesses, first)) { // couldn't find a definitive match, return nothing and we'll handle // this further up return(null); } var otherSide = likenesses.First().Collection; // got the other side of the relationship // lets make sure that the side that we're on now (mapping!) // is actually the relationship we want mapping = FindAlternative(rs, mapping, otherSide) ?? mapping; mapping.OtherSide = otherSide; otherSide.OtherSide = mapping; return(mapping); }
static bool both_collections_point_to_each_others_types(CollectionMapping left, CollectionMapping right) { return left.ContainingEntityType == right.ChildType && left.ChildType == right.ContainingEntityType; }
static CollectionMapping PairExactMatches(IEnumerable <CollectionMapping> rs, CollectionMapping current, IEnumerable <CollectionMapping> potentialOtherSides) { var otherSide = potentialOtherSides.Single(); // got the other side of the relationship // lets make sure that the side that we're on now (mapping!) // is actually the relationship we want var mapping = FindAlternative(rs, current, otherSide) ?? current; mapping.OtherSide = otherSide; otherSide.OtherSide = mapping; return(mapping); }
static CollectionMapping PairFuzzyMatches(IEnumerable<CollectionMapping> rs, CollectionMapping current, IEnumerable<CollectionMapping> potentialOtherSides) { // no exact matches found, drop down to a levenshtein distance var mapping = current; var likenesses = potentialOtherSides .Select(x => GetLikeness(x, current)) .Where(likeness_within_threshold) .OrderBy(x => x.Differences); var first = likenesses.FirstOrDefault(); if (first == null || AnyHaveSameLikeness(likenesses, first)) { // couldn't find a definitive match, return nothing and we'll handle // this further up return null; } var otherSide = likenesses.First().Collection; // got the other side of the relationship // lets make sure that the side that we're on now (mapping!) // is actually the relationship we want mapping = FindAlternative(rs, mapping, otherSide) ?? mapping; mapping.OtherSide = otherSide; otherSide.OtherSide = mapping; return mapping; }
/// <summary> /// Use an array /// </summary> /// <typeparam name="TIndex">Index type</typeparam> /// <param name="indexSelector">Index property</param> /// <param name="customIndexMapping">Index mapping</param> public T AsArray <TIndex>(Expression <Func <TChild, TIndex> > indexSelector, Action <IndexPart> customIndexMapping) { collectionBuilder = attrs => CollectionMapping.Array(attrs); return(AsIndexedCollection(indexSelector, customIndexMapping)); }
public ManyToManyCollectionInstance(CollectionMapping mapping) : base(mapping) { nextBool = true; this.mapping = mapping; }