public void ComponentMappingDemo()
{
//show how " /> 国产欧美日韩另类一区乌克兰,特级全黄一级毛片视频,超91视频

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

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

主站蜘蛛池模板: 色偷偷7777www人 | 日本精品一二三区 | 91短视频版在线观看免费 | 久久亚洲日本不卡一区二区 | 在线小视频国产 | 精品国产自在现线看久久 | 天天色天天射天天操 | 欧美图片另类小说综合 | 亚洲欧洲无码一区二区三区 | 热re66久久精品国产99re | 欧美黑人巨大日本人又爽又色 | 免费高清视频日本 | 狂野欧美性猛交xxxx免费按摩 | 久久久久久久久影院 | 伊人久久影院大香线蕉 | 日本高清午夜色wwwσ | 亚洲十欧美十日韩十国产 | 2021最新国产成人精品免费 | www激情网 | 久久成人永久免费播放 | 思思久热re6这里有精品 | 中文字幕美日韩在线高清 | 色网站免费看 | 成人黄网大全在线观看 | 国产欧美曰韩一区二区三区 | 亚洲欧洲在线观看 | 国产成人自拍视频在线观看 | 高清国产美女一级毛片 | 久草热视频在线 | 国产福利在线观看永久免费 | 国产福利一区二区三区在线视频 | 亚洲国产成人超福利久久精品 | 日韩视频一区二区 | 色久悠悠色久在线观看 | 欧美亚洲综合另类成人 | 久久久久综合网 | 国产乱码视频 | 亚洲91在线 | 91久久精品国产91久久性色也 | 亚洲欧美视频一区二区三区 | 国产一区二区精品久 |