public void ComponentMappingDemo()
{
//show how " /> 在线播放国产视频,国产欧美精品一区二区三区四区,天天干天天操

中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

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語義,轉載需保留來源!

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

主站蜘蛛池模板: 亚洲天堂影院 | 免费亚洲成人 | 欧美国产日韩在线 | 国产精品美女一区二区三区 | 天天色综网 | 综合激情网 | 在线午夜电影 | 亚洲一区二区三区欧美 | 成人国产精品入口免费视频 | 午夜天堂 | 一区二区电影网 | 天堂成人国产精品一区 | 国产久 | 久久网站黄| 色综合一区二区 | 91精品国产综合久久久久久 | 国产精品国产a级 | 一区二区三区在线免费看 | 午夜免费av | 欧美一级久久 | 青青草原精品99久久精品66 | 91精产国品一二三区 | 特黄特色大片免费视频观看 | 成人福利电影 | 国产日产欧产精品精品推荐蛮挑 | 久草在线 | 久久99精品久久久水蜜桃 | 日韩二三区 | 国产区在线观看 | 91久久久久久久久久久久久 | 成人在线视频一区 | 成人福利网站 | 黄色在线网站 | 中文字幕 欧美 日韩 | 久久久久久久久久久久91 | 亚洲国产精品视频一区 | 亚洲国产成人精品一区二区 | 久草网址| 天堂成人国产精品一区 | 91精品国产日韩91久久久久久 | 色网站在线免费观看 |