Many To One without having both the entity and Id present?

Apr 9, 2009 at 4:28 PM
Edited Apr 9, 2009 at 4:33 PM
Does anyone know how to map a Many To one with out having the id member present?

Id,  Name, Type

Id, TypeName

Person has a column Type_ID

I want to define an association on Person to PersonType without having to have both the member Type and TypeId?

May 7, 2009 at 1:50 AM
There is no support for this at present.  You would have to invent a new QueryMapping to do this.
Aug 1, 2012 at 2:23 PM
Edited Aug 1, 2012 at 2:41 PM

Probably the asker does not need any help any more but still I would like to answer for future reference.

Here is a work-around for duplicate association for foreign entity/table.

Person {
	// Use this valid way to set/associate Type
	// Use read-only property
	public int TypeId
		get { return Type == null ? 0 : Type.Id; }

PersonType {

<!-- Entity Map -->
<?xml version="1.0" encoding="utf-8"?>
  <Entity Id="PersonType">
    <Table Name="PersonTypes" />
    <Column Member="Id" IsPrimaryKey="true" IsGenerated="true" />
    <Column Member="TypeName" />
  <Entity Id="Person">
    <Table Name="Persons" />
    <Column Member="Id" IsPrimaryKey="true" IsGenerated="true" />
    <Column Member="TypeId" />
    <Association Member="Type" KeyMembers="TypeId" RelatedEntityID="PersonType" RelatedKeyMembers="Id" />

Also the Person entity needs to take care that its Type gets saved and Person.Type gets syncronised (Person.Type = syncronisedType).

So the Person entity still needs both the Type and TypeId properties but only Type can be set.