Paul:

Thanks for your explanation, but I have only one idea when Alterations
can be needed - when we need some adjustments to mapping for special
type of dbms, can you tell me another intention behind Alterations?
So I sure that Conventions is thing that applies only when user not
set properties explicitly - and Conventions can be overriden (and may
be not once) but never overrides anything.

And another problem - currently I not find any way to override
Conventions parameters. Needs something like:
        public static void AddMappingsFromAssembly(this Configuration
configuration, Assembly assembly, Convention conventions)
On Oct 6, 5:05 am, "Paul Batum" <[EMAIL PROTECTED]> wrote:
> Hi Pavel,
>
> I thought a quick explanation of the difference between SetAttribute and
> AddAlteration might be useful.
>
> When the mapping is consumed, a process occurs where conventions are
> applied. Due to the way this is implemented, values that were set using
> SetAttribute will get overridden by the conventions. The AddAlteration
> method basically buffers the specified change to occur after the conventions
> are applied, so that it cannot be overridden by them.
>
> The behaviour you witnessed can indeed be confusing, we probably need to
> spend some time looking at how conventions are applied.
>
> Paul Batum
>
> On Mon, Oct 6, 2008 at 12:07 AM, Pavel Samokha <[EMAIL PROTECTED]> wrote:
>
> > Ouh, I didn't notice it - I expected something like Length() or
> > SetLength(), and yes - it does what I want, Thank you, James.
> > But, I look at the code and saw that this method use AddAlteration:
>
> >        public PropertyMap WithLengthOf(int length)
> >        {
> >            if (this._property.PropertyType == typeof(string))
> >                this.AddAlteration(x => x.SetAttribute("length",
> > length.ToString()));
> >            else
>
> > So, my question is still actual.
>
> > On Oct 6, 1:58 am, "James Gregory" <[EMAIL PROTECTED]> wrote:
> > > Have you tried the WithLengthOf method? The SetAttribute method is really
> > > only there for situations where we haven't implemented the feature yet
> > and
> > > its causing people problems.
>
> > > On Sun, Oct 5, 2008 at 10:52 PM, Pavel Samokha <[EMAIL PROTECTED]>
> > wrote:
>
> > > > Playing today with Fluent NHibernate (from trunk) while prototyping
> > > > new project I found annoying thing - SchemaExport always produce me
> > > > "nvarchar(100)" for strings - so i try to understand why.
>
> > > > I used the following:
> > > > Map(x => x.Name).SetAttribute("length","1000");
>
> > > > And found that "length" attribute redefined in Conventions.AlterMap:
>
> > > >       public void AlterMap(IProperty property)
> > > >        {
> > > >            if (property.PropertyType == typeof(string))
> > > >            {
> > > >                property.SetAttribute("length",
> > > > DefaultStringLength.ToString());
> > > >            }
> > > >       ...
> > > >       }
>
> > > > and I really can't understand why? I found that I can use so-called
> > > > Alterations, but why I can't just set Attribute?
> > > > So I change code to the following, it doesn't break conventions but
> > > > give me ability to set length explicitly.
>
> > > >            if (property.PropertyType == typeof (string) && !
> > > > property.HasAttribute("length"))
> > > >            {
> > > >                property.SetAttribute("length",
> > > > DefaultStringLength.ToString());
> > > >            }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
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