You can use an IoC as the entity factory and have that inject a behavior. I am looking into using an IoC as well but haven't actually done it yet, but was assured that it works.
-Mark On Mon, May 4, 2009 at 1:14 PM, Rei Roldan <[email protected]> wrote: > > Map a constructor parameter ? Don't think that would be possible, instead > create a property on Employee of type IPaymentBehaviour and create a > subclass/joined-subclass (which ever makes sense). > > -----Mensaje original----- > De: [email protected] > [mailto:[email protected]] En nombre de KevinT > Enviado el: lunes, 04 de mayo de 2009 11:42 > Para: Fluent NHibernate > Asunto: [fluent-nhib] Map a Strategy Pattern using Fluent NHibernate > > > Essentially the title of this question explains the essense of what I > am trying to do, but to create a contrived example... > > I have a class, call it Employee. Employee has an IPaymentBehaviour... > > public class Employee > { > IPaymentBehaviour _paymentBehaviour; > > protected internal Employee() { /* required by NH */} > > public Employee(IPaymentBehaviour paymentBehaviour) > { > _paymentBehaviour = paymentBehaviour; > } > > } > > This corresponds to a database table like so: > > dbo.Employees > -> EmployeeId (primary key) > -> PaymentBehaviourId (foreign key to lookup table) > -> Field1 > -> Field2 > -> Field3 > -> Field4 > > Depending on the value of PaymentBehaviourId I need to 'inject' a > different implementation of IPaymentBehaviour into the Employee > object. Depending on which PaymentBehaviour was in use, Field1, 2, 3 > or 4 might be needed to create that behaviour (those are the actual > column names). > > Can anyone tell me how this would be mapped using Fluent-NHibernate? > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.5.287 / Virus Database: 270.12.17/2095 - Release Date: 05/04/09 > 06:00:00 > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
