public void ComponentMappingDemo()
{
//show how " /> 国产国语对白一区二区三区,涩涩亚洲,又爽又黄又无遮挡的视频在线观看

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

NHibernate3剖析:Mapping篇之ConfORM實戰(5):Component語義

  Component語義

  使用ConfORM“映射”組件,我們無需特別設置,ConfORM內部會根據Domain定義來判定組件,一般而言,沒有主鍵的類就是組件。

[Test]
public void ComponentMappingDemo()
{
//show how work with components and how ConfORM understands OOP
var orm = new ObjectRelationalMapper();
var mapper = new Mapper(orm);
//use the definition of table-to-class strategy class by class
orm.TablePerClass<Person>();
// Show the mapping to the console
var mapping = mapper.CompileMappingFor(new[] { typeof(Person) });
Console.Write(mapping.AsString());
}

  一些Domain范例

  我們使用各種集合定義Domain:

  1.Mapping a class with components

  Person實體有兩個組件:

public class Person
{
public int Id { get; set; }
public Name Name { get; set; }
public Address Address { get; set; }
}

public class Name
{
public string First { get; set; }
public string Last { get; set; }
}
public class Address
{
public string Street { get; set; }
public int CivicNumber { get; set; }
}

  Mapping

  輸出HbmMapping的映射字符串結果:

ClassWithComponents  2.Mapping a class with double usage of same component

  在上面Domain的基礎上新增一個Name類型的屬性:

public class Person
{
public int Id { get; set; }
public Name Name { get; set; }
public Name ShowBusinessAlias { get; set; }
public Address Address { get; set; }
}

  Mapping

  輸出HbmMapping的映射字符串結果:

ClassWithDoubleSameComponents  3.Collection of components

  使用一個集合,而不是單一組件:

public class Person
{
private Iesi.Collections.Generic.ISet<Address> addresses;
public Person()
{
addresses = new Iesi.Collections.Generic.HashedSet<Address>();
}
public int Id { get; set; }
public Name Name { get; set; }
public ICollection<Address> Addresses { get { return addresses; } }
}

  Mapping

  輸出HbmMapping的映射字符串結果:

CollectionOfComponents  4.Bidirectional relation

  實現實體與組件的雙向關聯關系:

public class Person
{
public int Id { get; set; }
public Name Name { get; set; }
public Name ShowBusinessAlias { get; set; }
public Address Address { get; set; }
}
public class Name
{
public Person Person { get; set; }
public string First { get; set; }
public string Last { get; set; }
}

  Mapping

  輸出HbmMapping的映射字符串結果:

BidirectionalRelation  結語

  這篇文章展示ConfORM的Components語義應用,映射了一些Domain示例。接下來繼續介紹ConfORM。Are you ConfORM?

  參考資料

  Fabio Maulo:ConfORM:“Mapping” Components

NET技術NHibernate3剖析:Mapping篇之ConfORM實戰(5):Component語義,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 成人十八影院在线观看 | youjizz日韩 | 国产一区三区二区中文在线 | 免费看黄色录像 | 久久精品亚洲精品国产色婷 | 91免费福利 | 亚洲国产成人久久笫一页 | 日本无吗免费一二区 | 伊人伊色 | 亚洲天堂图片 | 视频在线91 | 综合涩| 国产自愉自愉全免费高清 | 四虎精品影视 | 国产成人一区二区三区影院免费 | 日本免费新一区二区三区 | 婷婷久久综合九色综合九七 | 婷婷综合五月中文字幕欧美 | 国产中文字幕乱人伦在线观看 | 亚洲最大的成人网 | 91国内揄拍国内精品对白 | 日日插夜夜操 | 色久影院| 日本精品一区二区三本中文 | 色婷婷激婷婷深爱五月小说 | 六月丁香婷婷激情国产 | 国产最新精品精品视频 | 天天碰免费视频 | 青草资源站 | 精品日韩一区二区三区 | 91视频免费观看高清观看完整 | 久久综合偷偷噜噜噜色 | 毛片区 | 怡红院亚洲 | 国内精品欧美久久精品 | 不卡的毛片 | 91专区| 久久er这里都是精品23 | 国内自拍第1页 | 曰本还a大片免费无播放器 曰本视频网络www色 | 中文字幕亚洲一区 |