I have 3 entities:
class User {id,name...}
class UserUrl {id,user_id,url,url_type_id}
class UrlType {id,name}
My mapping:
<class name="User" table="Users" lazy="false">
<id name="id" type="Int32" column="id">
<generator class="identity" />
</id>
<property name="name" column="name" type="String"/>
<map name="Urls" table="UserUrl">
<key column="user_id"></key>
<index-many-to-many class="UrlType" column="url_type_id"/>
<one-to-many class="UserUrl"/>
</map>
</class>
<class name="UserUrl" table="UserUrl">
<id name="id" type="Int32" column="id">
<generator class="identity"/>
</id>
<property name="user_id" column="user_id" type="Int32"/>
<many-to-one name="UrlType" column="url_type_id" class="UrlType"/>
<property name="Url" column="url" type="String" not-null="true"/>
</class>
>
So User.Urls is IDictionary<UrlType,UserUrl>
. But I want to get Dictionary<string,UserUrl>
, where string key is UrlType.name.
Does anybody know how to do this?
相关问题
- F#: Storing and mapping a list of functions
- How to get coordinates of an svg?
-
NHibernate Query
with detached criteria… - Fluent NHibernate automap PostGIS geometry type
- Using NHibernate to execute DDL statements
相关文章
- Fluent NHibernate — Saving Entity with Composite K
- Is this the right way of using ThenFetch() to load
- Can Persistence Ignorance Scale?
- How to find if a referenced object can be deleted?
- Why can't I pass const map structure to a func
- NHibernate SQL query slow
- Scala: getting the key (and value) of a Map.head e
- NHibernate: How to perform eager subselect fetchin
I find out desition.
Mapping:
Code:
Use:
But It is spend more time to get ids of Urls types from DB
NHibernate will give you an interface for collections, in this case IDictionary as its implementation will involve proxies and caching and you won't want to know the details. So you won't get a Dictionary.
My question would be why do you want a Dictionary, you access all the data via the IDictionary interface what extra functionality would a concrete class give?