public void ShouldWriteMapForMapMapping() { var mapping = CollectionMapping.Map(); writer.VerifyXml(mapping) .RootElement.HasName("map"); }
// I'm not proud of this. The fluent interface for maps really needs to be rethought. But I've let maps sit unsupported for way too long // so a hack is better than nothing. /// <summary> /// Use a map collection /// </summary> /// <typeparam name="TIndex">Index type</typeparam> /// <param name="customIndexMapping">Index mapping</param> /// <param name="customElementMapping">Element mapping</param> public T AsMap <TIndex>(Action <IndexPart> customIndexMapping, Action <ElementPart> customElementMapping) { collectionBuilder = attrs => CollectionMapping.Map(attrs); AsIndexedCollection <TIndex>(string.Empty, customIndexMapping); Element(string.Empty); customElementMapping(elementPart); return((T)this); }
public void ShouldNotWriteCollectionTypeWhenEmpty() { var mapping = CollectionMapping.Map(); mapping.Set(x => x.CollectionType, Layer.Defaults, TypeReference.Empty); writer.VerifyXml(mapping) .DoesntHaveAttribute("collection-type"); }
public void ShouldWriteMap() { var mapping = new SubclassMapping(SubclassType.JoinedSubclass); mapping.AddCollection(CollectionMapping.Map()); writer.VerifyXml(mapping) .Element("map").Exists(); }
public void ShouldWriteMaps() { var mapping = new ComponentMapping(ComponentType.DynamicComponent); mapping.AddCollection(CollectionMapping.Map()); writer.VerifyXml(mapping) .Element("map").Exists(); }
public void ShouldWriteMaps() { var mapping = CreateInstance(); mapping.AddCollection(CollectionMapping.Map()); writer.VerifyXml(mapping) .Element("map").Exists(); }
public void ShouldWriteElement() { var mapping = CollectionMapping.Map(); mapping.Set(x => x.Element, Layer.Defaults, new ElementMapping()); writer.VerifyXml(mapping) .Element("element").Exists(); }
public void ShouldWriteCacheElement() { var mapping = CollectionMapping.Map(); mapping.Set(x => x.Cache, Layer.Defaults, new CacheMapping()); writer.VerifyXml(mapping) .Element("cache").Exists(); }
public void ShouldWriteIndexElement() { var mapping = CollectionMapping.Map(); mapping.Set(x => x.Index, Layer.Defaults, new IndexMapping()); writer.VerifyXml(mapping) .Element("index").Exists(); }
public void ShouldWriteRelationshipElement() { var mapping = CollectionMapping.Map(); mapping.Set(x => x.Relationship, Layer.Defaults, new OneToManyMapping()); writer.VerifyXml(mapping) .Element("one-to-many").Exists(); }
public void ShouldWriteKey() { var mapping = CollectionMapping.Map(); mapping.Set(x => x.Key, Layer.Defaults, new KeyMapping()); writer.VerifyXml(mapping) .Element("key").Exists(); }
/// <summary> /// Use a map collection /// </summary> /// <typeparam name="TIndex">Index type</typeparam> /// <param name="indexSelector">Index property</param> /// <param name="customIndexMapping">Index mapping</param> /// <param name="sort">Sorting</param> public T AsMap <TIndex>(Expression <Func <TChild, TIndex> > indexSelector, Action <IndexPart> customIndexMapping, SortType sort) { collectionBuilder = attrs => { var collection = CollectionMapping.Map(attrs); collection.Set(x => x.Sort, Layer.UserSupplied, sort.ToLowerInvariantString()); return(collection); }; return(AsIndexedCollection(indexSelector, customIndexMapping)); }
/// <summary> /// Use a map collection /// </summary> /// <typeparam name="TIndex">Index type</typeparam> /// <typeparam name="TComparer">Comparer</typeparam> /// <param name="indexColumnName">Index column name</param> public T AsMap <TIndex, TComparer>(string indexColumnName) where TComparer : IComparer <TChild> { collectionBuilder = attrs => { var collection = CollectionMapping.Map(attrs); collection.Set(x => x.Sort, Layer.UserSupplied, typeof(TComparer).AssemblyQualifiedName); return(collection); }; AsIndexedCollection <TIndex>(indexColumnName, null); return((T)this); }
/// <summary> /// Use a map collection /// </summary> /// <typeparam name="TIndex">Index type</typeparam> /// <param name="indexColumnName">Index column name</param> /// <param name="sort">Sorting</param> public T AsMap <TIndex>(string indexColumnName, SortType sort) { collectionBuilder = attrs => { var collection = CollectionMapping.Map(attrs); collection.Set(x => x.Sort, Layer.UserSupplied, sort.ToLowerInvariantString()); return(collection); }; AsIndexedCollection <TIndex>(indexColumnName, null); return((T)this); }
/// <summary> /// Use a map collection /// </summary> /// <typeparam name="TIndex">Index type</typeparam> /// <param name="indexSelector">Index property</param> /// <param name="customIndexMapping">Index mapping</param> public T AsMap <TIndex>(Expression <Func <TChild, TIndex> > indexSelector, Action <IndexPart> customIndexMapping) { collectionBuilder = attrs => CollectionMapping.Map(attrs); return(AsIndexedCollection(indexSelector, customIndexMapping)); }
/// <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); }