public void ComponentMappingDemo()
{
//show how " /> 日韩免费高清一级毛片久久,国产90后美女露脸在线观看,国产成人aa免费视频

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

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

主站蜘蛛池模板: 一级特黄国产高清毛片97看片 | 九九这里只有精品视频 | 国产无套在线观看视频 | 国产一级精品高清一级毛片 | 婷婷综合色伊人阁 | 国产一级久久免费特黄 | 国产成人在线视频免费观看 | 成人午夜在线观看国产 | 天堂成人精品视频在线观 | 国产成在线人视频免费视频 | 97色精品视频在线观看免费 | 国产成人最新毛片基地 | 99国产精品一区二区 | 亚洲第一网站 | 国产成人精品999在线观看 | 日韩理论视频 | 国产自产c区 | 中文字幕日韩欧美一区二区三区 | 午夜视频久久久久一区 | 亚洲激情视频在线 | 成人福利在线看 | 麻豆hd | 成人污视频在线观看 | 国产精品视频一区二区三区小说 | 好爽毛片一区二区三区四 | 色偷偷91久久综合噜噜噜 | 91精品全国免费观看含羞草 | 狼人综合伊人 | 精品国产一区二区二三区在线观看 | 欧美一级一一特黄 | 亚洲一区免费视频 | 亚洲国产精品第一页 | 国产原创视频在线 | 美国人和狍xxxx视频 | 亚洲综人网 | 丁香婷五月| 一级毛片特黄久久免费看 | 五月激情婷婷网 | 日韩在线观看一区 | 国产福利91精品一区二区三区 | 久久国产精品超级碰碰热 |