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

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

主站蜘蛛池模板: 亚洲一区二区三区在线免费观看 | 黄视频在线观看免费 | 国产好吊妞视频在线观看 | 手机在线色 | 真人一级毛片国产 | 成人精品第一区二区三区 | 欧美xxxwww | 婷婷六月久久综合丁香可观看 | 国产午夜精品视频 | 视频国产一区 | 浮力影院第一页小视频国产在线观看免费 | 在线看黄网址 | 欧美视频 亚洲视频 | 精品国产乱码一区二区三区 | 激情五月亚洲 | 色网站免费视频 | 亚洲黄色在线观看视频 | 91在线在线啪永久地址 | 九九久久免费视频 | 美妇乱人伦性 | 亚洲伦理一区二区三区 | 久久久午夜视频 | 999影院成 人在线影院 | 色多多视频官网 | 日韩亚洲欧美一区噜噜噜 | 在线 色 | 美女色黄网站 | 9久9久女女免费精品视频在线观看 | 奇米亚洲春色 | www.四色.com| 亚洲欧美成人永久第一网站 | 丁香五月情 | 免费看一区二区三区 | 97成人免费视频 | 黄色网页在线免费观看 | 免费国产在线观看不卡 | 男人精品网站一区二区三区 | 久久综合加勒比 | 一二三四在线视频社区1 | 色噜噜国产在线91蝌蚪 | 91精品啪在线观看国产日本 |