public void ComponentMappingDemo()
{
//show how " /> 国产人妖ts丝丝 magnet,成年18网站免费视频网站,国产亚洲一路线二路线高质量

一区二区久久-一区二区三区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語義,轉載需保留來源!

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

主站蜘蛛池模板: 国产成人aa视频在线观看 | 亚洲福利视频网址 | 骚碰97| 国产一区二区在免费观看 | 成人影视大全 | 视频国产一区 | 国产精品98福利小视频 | 国产午夜三区视频在线 | 一区一精品 | a亚洲va韩国va欧美va久久 | 毛片久久| 岛国毛片| 亚洲福利秒拍一区二区 | 日韩精品视频免费网址 | 亚洲人成77777在线观看网 | 欧美日韩一区二区三区自拍 | 国产对白在线播放九色 | 国产婷婷一区二区在线观看 | 成年wwxx视频免费中文 | 亚洲国产一区二区三区亚瑟 | 成人在线免费观看视频 | 伊人第四色 | 色久悠悠在线观看 | 天天爽天天爽 | 精品国产一区二区三区2021 | 91精品久久久久久久久久 | 亚洲欧美日韩国产一区二区三区精品 | 99久久中文字幕伊人 | 97色精品视频在线观看免费 | 国产三级全黄 | 亚洲国产视频网 | 在线视频一区二区 | 国内外成人免费在线视频 | 日本红怡院在线 | 中文字幕一区在线观看视频 | 亚洲网美女| 久久国产成人精品麻豆 | 日日爽天天干 | 免费观看四虎精品国产永久 | 一区二区三区在线免费视频 | 一区二区视频在线播放 |