public void ComponentMappingDemo()
{
//show how " /> 37大但人文艺术A级都市天气,亚洲乱码国产乱码精品精98,爱穿丝袜的麻麻3d漫画acg

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

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

主站蜘蛛池模板: 久久综合久久鬼 | 国产精品999 | 亚洲精品色情APP在线下载观看 | 国产亚洲日韩另类在线观看 | 亚洲欧美高清在线精品一区 | 性虎成人网 | 无码国产成人午夜在线观看不卡 | 精品无码国产自产在线观看水浒传 | 毛片免费大全 | 国产啪精品视频网免费 | 先锋资源久久 | 国产精品久久久久久AV免费不卡 | 蜜桃AV色欲A片精品一区 | 亚洲免费黄色 | 日韩亚洲国产欧美免费观看 | 夜夜精品视频一区二区 | 麻豆成人啪啪色婷婷久久 | 国产1广场舞丰满老女偷 | yin荡体育课羞耻play双性 | 芭乐视频免费资源在线观看 | 毛片免费在线播放 | seyeye免费高清观看 | 视频一区视频二区ae86 | 亚洲精品免费在线视频 | 性欧美13处14处破 | 免费国产成人手机在线观看 | vr亚洲成年网址在线观看 | 麻豆高清区在线 | 成人欧美尽粗二区三区AV | 97国产精品久久精品国产 | 性VIDEOSTV另类极品 | 午夜成a人片在线观看 | 97caopeng| 国内精品人妻无码久久久影院蜜桃 | 成人在线精品视频 | 国产乱子影视频上线免费观看 | 国产产乱码一二三区别免费 | 成年免费三级视频 | 国产野外无码理论片在线观看 | 中文字幕成人在线观看 | 扒开美女的内衣亲吻漫画 |