public void ComponentMappingDemo()
{
//show how " /> 亚洲精品久久久久69影院,20岁αsrian男同志免费,有码 亚洲 制服 国产 在线

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

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

主站蜘蛛池模板: 亚洲VA欧美VA天堂V国产综合 | 久久久久国产一级毛片高清片 | 国产睡熟迷奷系列网站 | 久久欧洲AV无码精品色午夜麻豆 | 一品道门免费视频韩国 | 青青草干免费线观看 | 欧美精品中文字幕亚洲专区 | 厨房玩朋友娇妻中文字幕 | 好男人好资源在线播放 | 人妻体体内射精一区二区 | 久久精品国产午夜伦班片 | 超碰免费碰免费视频 | chinese情侣自拍啪hd | 午夜伦理电影在线观免费 | 国产成人精品免费视频大全办公室 | 精品人妻无码一区二区三区蜜桃臀 | 国产高清视频免费在线观看 | 青青伊人影院 | 亚洲一区在线播放 | 色橹橹欧美在线观看视频高 | 久久无码av三级 | 久久re这里精品在线视频7 | 99免费在线 | 亚洲国产精品免费观看 | 果冻传媒2021一二三区 | 一本之道高清www在线观看 | 老司机午夜影院味味 | 亚洲精品国偷拍自产在线观看蜜臀 | 扒开胸罩揉她的乳尖视频 | 免费观看久久 | 日本A级作爱片金瓶双艳 | 黄片a级毛片 | 日韩爽爽影院在线播放 | jizz非洲| 国产伦精品一区二区三区免费 | 印度最猛性ⅹxxxxx | 无毒成人社区 | 一点色成人 | 亚洲AV久久无码精品蜜桃 | 超碰在线视频公开 | 午夜黄视频 |