1) Yeah, currently you need some form of setter

2) We do the same thing here and use a convention:

Fluently.Configure().Database
                (SQLiteConfiguration.Standard.InMemory().ShowSql())
                .Mappings(m =>
                              {
                                  m.AutoMappings.Add

(AutoPersistenceModel.MapEntitiesFromAssemblyOf<SecurityUser>()
                                           .Where(t =>
t.Namespace.EndsWith("Security"))
                                           *.ConventionDiscovery

.AddFromAssemblyOf<SecurityUser>);*
                              }).BuildSessionFactory();

public class HasManyConvention : IHasManyConvention
    {
        public bool Accept(IOneToManyPart target)
        {
            return true;
        }

        public void Apply(IOneToManyPart target)
        {
            target.AsSet().Access.AsCamelCaseField();
        }
    }



On Thu, Jul 23, 2009 at 1:53 AM, dnagir <[email protected]> wrote:

>
> Hi,
>
> I have the class below. FNH does not seem to generate mapping for the
> association without a setter (SecondaryGroups).
> If I add the private setter it does generate the mapping but I don't
> know how to implement the setter in this case as a backing store of
> the field is HashSet and value in the setter is IEnumerable<>.
>
> So 2 questions:
> 1. Is it possible to tell FNH to generate mapping for associations
> without setter?
> 2. If No, how should I implement the setter.
>
> Cheers,
> Dmitriy.
>
> CONFIGURATION IS:
> factory = Fluently.Configure()
>                            .Database
> (SQLiteConfiguration.Standard.InMemory().ShowSql())
>                            .Mappings(m => {
>                                m.AutoMappings.Add
> (AutoPersistenceModel.MapEntitiesFromAssemblyOf<SecurityUser>()
>                                    .Where(t => t.Namespace.EndsWith
> ("Security")));
>                            }).BuildSessionFactory();
>
>
> CLASS IS:
>
> public class SecurityUser {
>
>        public SecurityUser() {
>                additionalPrivileges = new HashSet<SecurityPrivilege>();
>        }
>
>        public virtual int Id { get; set; }
>        public virtual string Username { get; set; }
>        public virtual bool Enabled { get; set; }
>        protected virtual string Password { get; set; }
>        // wrapped in method... omitted here...
>
>        public virtual SecurityGroup MainGroup { get; protected set; }
>        // wrapped in method... omitted here...
>
>        private HashSet<SecurityGroup> secondaryGroups;
>        public virtual IEnumerable<SecurityGroup> SecondaryGroups {
>                get {
>                        return secondaryGroups;
>                }
>                // Setter is required by (Fluent?)NHibernate. Otherwise
> Fluent does
> not generates correct mapping
>                private set {
>                        throw new NotImplementedException("I don't know how
> to implement
> this correctly");
>                }
>        }
>
>        public virtual SecurityUser AddSecondaryGroup(SecurityGroup g)
> {
>                if (g == null)
>                        return this;
>                secondaryGroups.Add(g);
>                return this;
>        }
> }
>
> >
>


-- 
"Any fool can write code that a computer can understand. Good programmers
write code that humans can understand."
-Martin Fowler et al, Refactoring: Improving the Design of Existing Code

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

Reply via email to