Hmm..then my code should work too..i'll have to take a closer look on
Monday.

But.... I think what you're saying makes sense if you were invoking
the funcion declared in the lamda within the same scope; it would use
the temp variable declared in the loop. But, in this case, the
function is invoked in a different class (RefelectionHelper I
believe), and that class doesn't declare a variable called temp.
Also, I can't remember the code now,  but I don't think fluent ever
invokes the funciotn declared by the lambda; it just examines the
expression tree to pull out properties for the purposes of generating
the mapping. And when it does, it won't know what to do w/ "temp".
Hopefully I'm wrong. :)

On Jun 20, 12:19 pm, James Gregory <[email protected]> wrote:
> Rob: Just FYI, as far as I understand temp will still exist at the time
> because it's used within the closure. .Net imports that variable into the
> lambda's scope.
>
> On Sat, Jun 20, 2009 at 4:32 PM, Pablo Ruiz <[email protected]> wrote:
>
> > private void SetupComponentParts(DynamicComponentPart<IDictionary> part)
> > {
> >    IList<string> dynamicColumns = GetCustomerColumns();
> >    foreach(string col in dynamicColumns)
> >    {
> >      string temp = col; // Avoid any modified closure issues.
> >      c.Map(x => (string)x[temp]);
> >    }
> > }
>
> > DynamicComponent(x => x.AdditionalFields, c => SetupComponentParts(c));
>
> > That's it..
>
> > On Sat, Jun 20, 2009 at 5:11 PM, rob <[email protected]> wrote:
>
> >> Funny...this is exactly my situation. See my post on Dynamic
> >> components from a couple days ago. Unfortunately, this statement won't
> >> work:
> >>  c.Map(x => (string)x[temp]);
>
> >> because the variable temp isn't evaluated in the loop; the statement
> >> is turned into an expression tree and evaluated later; at which time
> >> "temp" won't exist. I've been trying all sorts of things the past few
> >> days, and may be close to a solution involvoing manually building the
> >> expression tree. Should know more on Monday. Keep me posted if you
> >> figure something out!
>
> >> On Jun 20, 8:45 am, Paul Batum <[email protected]> wrote:
> >> > Hi Silvia,
>
> >> > Can the column details be discovered at startup time? I'm thinking of
> >> > something like this:
>
> >> > IList<string> dynamicColumns = GetCustomerColumns();
> >> > DynamicComponent(x => x.AdditionalFields, c =>{
> >> >   foreach(string col in dynamicColumns)
> >> >   {
> >> >     string temp = col; // Avoid any modified closure issues.
> >> >     c.Map(x => (string)x[temp]);
> >> >   }
>
> >> > });
>
> >> > Paul Batum
>
> >> > On Tue, Jun 16, 2009 at 10:10 AM, Silvia <[email protected]> wrote:
>
> >> > > I have the below situation that I need help figure it out.
> >> > > I am using fluent nhibernate with a legacy database. I need to map
> >> > > some additional columns to a dictionary(?) property in my entity
> >> > > dynamically, because I do not know the number of columns and column
> >> > > names and other specifications at compile time and I dynamically need
> >> > > to work with those columns(insert,update...).There is another object
> >> > > which has those information and has a relationship with my main entity
> >> > > based on the value of two other columns.Is this possible in
> >> > > nhibernate?
> >> > > I tried to use DynamicComponent but the problem is I don't know what
> >> > > would be the properties in my component.
> >> > > I have something like this:
>
> >> > > In Entity.cs :
> >> > > public virtual IDictionary AdditionalFields { get; set; }
> >> > > public virtual  Info AdditionalFieldsInfo{get; set;}
>
> >> > > And in  EntityMap.cs:
> >> > > References(x => x.AdditionalFieldsInfo);
> >> > > and I supposedly should have something like this:
> >> > > DynamicComponent(x => x.AdditionalFields , m =>
> >> > > {
> >> > > m.Map(?Which I don't know how to map because I dont have the number of
> >> > > columns to be mapped and column names.These information needs to come
> >> > > from AdditionalFieldsInfo);
> >> > > });
>
> >> > > I also posted the question to nhusers group([email protected])
> >> > > but I still not very sure how to implement this.
> >> > > I do appreciate if someone could help.
> >> > > Thanks.
> >> > > Silvia
--~--~---------~--~----~------------~-------~--~----~
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