Rob: Do you have Resharper installed by any chance? If so, does it complain
about any scope issues with your i variable?

On Fri, Jun 19, 2009 at 3:50 PM, Hudson Akridge <hudson.akri...@gmail.com>wrote:

> What I'm thinking is happening here, is that since linq stuff is all
> deferred execution, when it's finally called, i is out of scope and doesn't
> exist (the null ref exception he's getting). If there's a way to force
> mapping() to be evaluated immediately when it's referenced on
> DynamicComponent, that might resolve the issue.
>
> Of course, I could be way off :)
>
> On Fri, Jun 19, 2009 at 9:42 AM, James Gregory <jagregory....@gmail.com>wrote:
>
>> I'm guessing it's something todo with the way the ReflectionHelper is
>> working on it, so it may require a code change on our part.
>>
>> On Fri, Jun 19, 2009 at 3:05 PM, Hudson Akridge <hudson.akri...@gmail.com
>> > wrote:
>>
>>> Very strange. Have you tried perhaps an explicit i.ToString()? Or a
>>> string.Format("property{0}",i)?
>>>
>>>
>>> On Fri, Jun 19, 2009 at 8:55 AM, rob <rj...@yahoo.com> wrote:
>>>
>>>>
>>>> Doesnt' work. If I used any variable or even a hardcoded integer (as
>>>> in x["properytname" + 3])  inside the x[...] statement I get the
>>>> error.
>>>>
>>>> On Jun 19, 4:15 am, James Gregory <jagregory....@gmail.com> wrote:
>>>> > What happens if you declare a variable that contains the property
>>>> name?
>>>> >
>>>> > for (int i = 0; i < 1; i++)
>>>> > {
>>>> >   var propertyName = "property" + i;
>>>> >
>>>> >   c.Map(x => x[propertyName], "columname" + i);
>>>> >
>>>> > }
>>>> > On Fri, Jun 19, 2009 at 1:15 AM, rob <rj...@yahoo.com> wrote:
>>>> >
>>>> > > Hi-
>>>> >
>>>> > > I'm using the latest release (524) of Fluent and am running into an
>>>> > > issue. I have a class that contains some regular properties and an
>>>> > > IDictionary property (for the dynamic component). My hope is to
>>>> > > dynamically build the column and property names in the fluent map
>>>> for
>>>> > > the dynamic component using a loop. Here's what I have:
>>>> > > When I run this, I get the follwing exception "Object reference not
>>>> > > set to an instance of an object." Basically, it doensn't like having
>>>> a
>>>> > > variable inside the dictionary key object. If I change it to x
>>>> > > ["property"] ti works fine. And it doesnt' complain about
>>>> "columnname"
>>>> > > + i. Any ideas? workarounds?  Thanks..
>>>> >
>>>> > > public class TestMap: ClassMap<TestMap>
>>>> > >    {
>>>> >
>>>> > >        private Action<DynamicComponentPart<IDictionary>> mapping()
>>>> > >        {
>>>> >
>>>> > >            return c =>
>>>> > >             {
>>>> > >                 for (int i = 0; i < 1; i++)
>>>> > >                 {
>>>> > >                     c.Map(x => x["property" + i], "columname" + i);
>>>> > >                 }
>>>> > >             };
>>>> > >        }
>>>> >
>>>> > >        public TestMap()
>>>> > >        {
>>>> > >            Id(x => x.Id);
>>>> > >            Map(x => x.Gender).WithLengthOf(1);
>>>> > >            this.DynamicComponent(x => x.DynamicProperties, mapping
>>>> > > ());
>>>> > >        }
>>>> > >    }
>>>>
>>>>
>>>
>>>
>>> --
>>> - Hudson
>>> http://www.bestguesstheory.com
>>> http://twitter.com/HudsonAkridge
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> - Hudson
> http://www.bestguesstheory.com
> http://twitter.com/HudsonAkridge
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 
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