I was wondering if anyone had some examples of any ways they have
solved functional programming issues with nHibernate (or Fluent). To
be clear, by functional I am referring to using anonymous functions
and method deconstruction as part of the serialized data, similar to
the way Javascript and (to my [EXTREMELY LIMITED] understanding) F#
works.

I have a situation where I need to call upon complicated anonymous
methods, however the context that they are called in is impossible to
'know' at database save time. I need to store the logic to 'unwrap'
references, as it were, where the references are nhibernate backed
DTOs. So for my example..

class Aspect { // ... }

class Observable {
     virtual Aspect Aspect { get; set; }
     virtual double __latest_value { get; set; }
}

class Mutation {
   virtual Aspect Aspect { get; set; }
   virtual double Value { get; set; }
}

__latest_value does not come from the "Aspect" class, but instead it
comes from taking Mutations of data relative to the context of what is
being observed. So then, a User might have 50 mutations to a single
Aspect. The Observable is used in a mathematical function, and is to
represent the value in relationship to the current User, but because
the Aspect itself is a late-bound object (not hard-coded by name/id),
I cannot just pass the exact object through the formula. So, in this
instance I am coding for a game. I cannot say ..

var Health = ( Character["Stamina"] * 3 );

because "Stamina" (an Aspect) doesn't exist. The "Character" has a
list of Mutations, each of which might look like this.

Character.Mutations[0] = { Aspect = (stamina aspect), Value = 1.0 };
Character.Mutations[1] = { Aspect = (stamina aspect), Value = 3.0 };

(( this is NOT how my muations are structured, I am just using this as
the absolute most simplistic, basic example ))

Because "Stamina" is nothing but a string literal for the name of an
aspect, I cannot use it in computation. I would have to have the
appropriate Aspect Id. That is not known until the Aspect is saved to
the database. And even if I knew the ID, Hard-coding math against a
database Id by string literal is bad practice. So my solution is to
wrap things that need to be 'unwrapped' into this "Observable" class.

I am wondering if there is any way that nHibernate can help me with
this logic. If there is anything I can do to make it a simpler
process. I have tried the following;

MetaLinq - Serializing Lambda Expressions to XML
  - This worked, but it was too slow and proved to yield massive
record sizes.
ExpressionSerialization
  - Couldn't get it to work with .NET 4.0, ended up defaulting back to
MetaLinq
Hard-Coded Anonymous Method Dictionary
  - Methods were coded and given a string literal name, and the
Parameters stored in the database. This is extremely unruly and hard
to maintain.

I am open to using HQL, but I do not know it, and I find it to be a
very confusing way of doing things. If anyone has any ideas/examples,
I would be very, very open to them. I am not against implementing new
libraries to solve it, if it will actually solve it.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to