Hi,

  I have been using an approach to map *dynamic* filters (filter
definitions that I use to store in the database) witch is adding *by
hand* the filter part, just like:

base.filters.Add(new FilterPart("MyFilter"));

  And in the mapping classes I have to add in a nothing nice approach.
I actually do that because I don't have an ApplyFilter method witch
receives just the name and condition, and the FluentMappingsContainer
just have methods witch receives the type of the mapping class so I
ask is if you could add two new methods to the class ClassMap<T> to
apply filters using their name in the mapping classes and one to the
FluentMappingsContainer witch would receive an already instantiated
class of IMappingProvider to be sent to the already public method
Add(IMappingProvider provider) of the PersistentModel class.

  The changes would be:

  a) ClassMap<T>:

        public ClassMap<T> ApplyFilter(string name)
        {
            return this.ApplyFilter(name, null);
        }

        public ClassMap<T> ApplyFilter(string name, string condition)
        {
            var part = new FilterPart(name, condition);
            filters.Add(part);
            return this;
        }

  b) FluentMappingsContainer:

        public FluentMappingsContainer Add(IMappingProvider mapping)
        {
            if (mapping == null)
                throw new ArgumentNullException("mapping");

            mappings.Add(type);
            WasUsed = true;
            return this;
        }


        internal void Apply(Configuration cfg)
        {
            foreach (var assembly in assemblies)
            {
                model.AddMappingsFromAssembly(assembly);
            }

            foreach (var type in types)
            {
                model.Add(type);
            }

            foreach (var mapping in mapping)
            {
                model.Add(mapping);
            }

            if (!string.IsNullOrEmpty(exportPath))
                model.WriteMappingsTo(exportPath);

            model.Configure(cfg);
        }

  In this way I can instantiate my mapping class, apply it's filters
and add it to the persistent model.

  Best regards,
  DM

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to