merging MappingConfiguration from many assemblies?

2 posts, 1 answers
    MATEUSZ avatar
    18 posts
    Member since:
    Jul 2011

    Posted 14 Oct 2011 Link to this post

    I'm trying to a achieve some specific behaviour and it turned out not to be so easy.

    Let's say that i in Core project i have:
    public class Car : IEntity
            public virtual int Id { get; set; }
            public static MappingConfiguration<Car> CreateConfiguration()
                var userMapping = new MappingConfiguration<Car>();
                userMapping.MapType(u => new
                    Id = u.Id,
                userMapping.HasProperty(u => u.Id).IsIdentity(KeyGenerator.Autoinc);
                return userMapping;
    public class MyFluentMetadataSource : FluentMetadataSource
            protected override IList<MappingConfiguration> PrepareMapping()
                return new List<MappingConfiguration>();

    I have a Test project too. When I want to use entities and metadatasource from Core project, everything works fine.
    Problem start when I want to palce some test entities and place them in Test project.
    I started from creating TestMetadataSource in Test project and enhacing it. However, either core or test entities configuration was acquired, but never simultaneously.

    So how should TestMetadataSource be implemented to acquire mapping configurations from both projects?
  2. Answer
    Ivailo avatar
    318 posts

    Posted 18 Oct 2011 Link to this post

    Hello Mateusz,

    In order to achieve that, you will have to merge the two MetadataSources to produce a new MetadataContainer holding both mappings and definitions. You can do that automatically through our AggregateMetadataSource class, as shown in the linked help article.

    I hope that this will answer your question. In any case, do not hesitate to contact us for further clarification or assistance.

    Best wishes,
    the Telerik team

    Check out the latest stable build of Telerik OpenAccess ORM. Download it and benefit from our new Project Templates.

  3. DevCraft banner
Back to Top