Hi,

  Just like I told in another post (http://groups.google.com/group/
fluent-nhibernate/t/9eb53f6447e9771a) I use to set some dynamic
filters on my entities. Actually I have to do a very ugly workaround
so I can acomplish that, for the definitions I have to emit code to
make the FilterDefinitions inherited classes and for the mapping
classes I have to set a static property with the filters witch it has
to Apply (when just it needs is the filter name). I think it should be
very better if you could add two more overloads in the
ClassMap<T>.ApplyFilter method, those should be:

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

  And the current one could be changed to:

        public ClassMap<T> ApplyFilter<TFilter>(string condition)
where TFilter : FilterDefinition, new()
        {
            return this.ApplyFilter(new TFilter().Name, condition);
        }

  That should solve part of my problem, second I would have the
FluentMappingsContainer.Add restricting me to add just types and
forcing me to emit code for the filter definitions as, also, set
static properties of my entities mapping classes so they know witch
filters should they apply when I could just instantiated then, set the
filters on then an pass this instance to the
FluentMappingsContainer.Add.

  Would be something like:

    public class FluentMappingsContainer
    {
        private readonly IList<IMappingProvider> mappings = new
List<IMappingProvider>();
        private readonly IList<IFilterDefinition> filters = new
List<IFilterDefinition>();
        ...
        public FluentMappingsContainer Add(IMappingProvider mapping)
        {
            mappings.Add(mapping);
            WasUsed = true;
            return this;
        }
        public FluentMappingsContainer Add(IFilterDefinition filter)
        {
            filters.Add(filters);
            WasUsed = true;
            return this;
        }
        internal void Apply(Configuration cfg)
        {
            foreach (var mapping in mappings)
            {
                model.Add(mapping);
            }

            foreach (var filter in filters)
            {
                model.Add(filter);
            }

            foreach (var assembly in assemblies)
            {
                model.AddMappingsFromAssembly(assembly);
            }

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

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

            model.Configure(cfg);
        }

  I have posted this last year (http://groups.google.com/group/fluent-
nhibernate/browse_thread/thread/fdc23fd8197d9bbc/
743077793216c027#743077793216c027) but got nothing, to my happiness I
haven't to change fluentnh code that time as in that case was for
dicriminating classes witch have it's behavior changed to use
SubclassMap<T>. I'm not posting a real case because the code is long
and uggly and I don't see that those overloads should be a major
change in the FluentNHibernate structure (enlighten me if I'm wrong),
all those code have been tested here and worked fine I just don't use
them because if I make a change on FluentNHibernate I'll have to peek
it on every new version I download, too messy, error prone,
whatever...

  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