WithTable with only one parameter sets the table name, with the lambda expression it uses the NHibernate <join> element to merge two tables; not very clear, I know. I'm clearing all this up soon.
On Mon, Jan 12, 2009 at 4:55 PM, Andrew Stewart < [email protected]> wrote: > Hi Brendan, > Why are you setting the table name twice, whats that second withTable for? > > WithTable("PartyContact"); > > WithTable("Contact",m=> {m.HasOne(t =>t.ContactSource);}); > > > Cheers > > Andy > > > On Mon, Jan 12, 2009 at 4:49 PM, brendanjerwin <[email protected]>wrote: > >> >> My Map: >> >> public ContactMap() >> { >> WithTable("PartyContact"); >> >> Id(c => c.ContactId, "ContactId"); >> >> HasOne(t => t.ContactRoleType); >> >> Map(c => c.FromDate); >> Map(c => c.ThroughDate); >> Map(c => c.Comments); >> >> WithTable("Contact",m=> >> { >> m.HasOne(t => >> t.ContactSource); >> }); >> >> >> } >> >> XML it produces: >> >> <?xml version="1.0" encoding="utf-8"?> >> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default- >> lazy="true" assembly="Clearwave.Integration.Models" >> namespace="Clearwave.Integration.Models.Contact"> >> <class name="Contact" table="PartyContact" xmlns="urn:nhibernate- >> mapping-2.2"> >> <id name="ContactId" column="ContactId" type="Int32"> >> <generator class="identity" /> >> </id> >> <property name="ThroughDate" column="ThroughDate" type="DateTime"> >> <column name="ThroughDate" /> >> </property> >> <property name="Comments" column="Comments" length="100" >> type="String"> >> <column name="Comments" /> >> </property> >> <property name="FromDate" column="FromDate" type="DateTime"> >> <column name="FromDate" /> >> </property> >> <one-to-one name="ContactRoleType" >> class="Clearwave.Integration.Models.Contact.ContactRoleType, >> Clearwave.Integration.Models, Version=1.0.0.0, Culture=neutral, >> PublicKeyToken=null" /> >> <join table="Contact"> >> <key column="ContactID" /> >> <one-to-one name="ContactSource" >> class="Clearwave.Integration.Models.Contact.ContactSource, >> Clearwave.Integration.Models, Version=1.0.0.0, Culture=neutral, >> PublicKeyToken=null" /> >> </join> >> </class> >> </hibernate-mapping> >> >> Exception it tosses: >> >> System.Xml.Schema.XmlSchemaValidationException: The element 'join' in >> namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'one- >> to-one' in namespace 'urn:nhibernate-mapping-2.2'. List of possible >> elements expected: 'property, many-to-one, component, dynamic- >> component, any, sql-insert, sql-update, sql-delete' in namespace >> 'urn:nhibernate-mapping-2.2'. >> >> Any ideas? Did I catch the code in-between working states? Is there a >> revision I should stick with for now? >> >> > > > -- > ================= > I-nnovate Software - Bespoke Software Development, uk wirral. > http://www.i-nnovate.net > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
