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

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

主站蜘蛛池模板: 精品日韩一区 | a免费视频 | 久久久久久一区 | 精品伊人 | 福利av在线| 精品国产一区二区久久 | 午夜精品在线观看 | 日本黄色片免费在线观看 | 亚洲网站免费看 | 国产精品揄拍一区二区 | 国内精品久久久久久影视8 最新黄色在线观看 | www国产亚洲精品久久网站 | 日韩一二区 | 亚洲综合色丁香婷婷六月图片 | av在线一区二区三区 | 日本三级精品 | 久久精品一区二区三区四区 | 日日做夜夜爽毛片麻豆 | 91精品久久久久久久久中文字幕 | 黄色欧美 | 免费av在线 | 国产一级视频 | 视频在线日韩 | 国产精品一区二区久久 | 国产精品久久久免费 | 久久黄色网 | 成人免费黄视频 | 麻豆国产一区二区三区四区 | 精品综合 | 超碰天天 | 国产精品片 | www.日日干 | 国产精品射| 91精品国产91久久久久游泳池 | 国产清纯白嫩初高生在线播放视频 | 毛片一级片 | 中文字幕日韩欧美一区二区三区 | 欧美日韩一区二区三区四区 | 欧美成人a∨高清免费观看 色999日韩 | 午夜电影在线播放 | 国产精品亚洲综合 |