2009-09-03 5 views
1

IUserTypeでマップされたエンティティの集合を持つことは可能ですか?たとえば:<propertyにIUserTypeマッピングを適用するために使用されるようIUserTypeインスタンスのコレクションを持てますか?

class Foo 
{ 
    public int Id { get; set; } 
    public ISet<Special> Items { get; set; } 
} 

class Special 
{ 
    public Special(string columnValue) 
    { 
     _val = columnValue; 
    } 

    public override string ToString() 
    { 
     return _val.TranformInInterestingWays(); 
    } 

    private string _val; 
} 

class SpecialUserTypeForMapping : IUserType 
{ 
    // assume that all the right stuff is here 
    // for using the non-default constructor on the way in 
    // and calling ToString() on the way out 
} 
私が正しくドキュメントを読んでいる場合は

、どちら<set>、<one-to-many>、<many-to-many>、また<class>要素は "type" 属性をサポートしています> s。だから私はこれをどのようにマップするのですか? DBから別のFooのインスタンスを取得

<class name="Foo" table="foos"> 
    <id name="Id" /> 
    <set name="Items" table="foo_special"> 
     <key column="fooId" /> 
     <element column="special_value" type="SpecialUserTypeForMapping" /> 
    </set> 
</class> 

は問題ありませんが、それはそれはに対してクエリを記述することができますかどうかは明らかではありません。

答えて

2

最も都合の解決策はそうのように、<element>要素を使用することのようです私のシナリオの要件であるspecial_value列。 This questionはそれがそうでないことを示すようです。

関連する問題