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

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

主站蜘蛛池模板: 超碰在线97av视频免费 | 久久久精品免费免费直播 | 亚洲精品入口一区二区乱麻豆精品 | 高清日本片免费观看 | 高h 大尺度纯肉 np快穿 | 婷婷激情综合色五月久久竹菊影视 | 99国产精品偷窥熟女精品视频 | 日韩熟女精品一区二区三区 | 国产午夜福利伦理300 | 免费A级毛片无码无遮挡 | 在公交车上被JB草坏了被轮J了 | 伊人亚洲AV久久无码精品 | 久久国产免费 | 在线日本高清日本免费 | 午夜dj影院视频观看 | 成人免费观看www视频 | 亚洲综合AV色婷婷五月蜜臀 | 久久影院午夜理论片无码 | 四虎永久免费网址 | 777福彩社区 | 久久免费电影 | 晓雪老师我要进你里面好爽 | 亚洲精品久久久无码一区二区 | 差差差差差差差差免费观看 | 久久国产综合精品欧美 | 三八成人网 | 99re在这里只有精品 | 欧美乱妇15p图 | 国产午夜免费视频片夜色 | 一本色道久久综合亚洲精品加 | 欧美一区二区三区久久综 | 国产精品免费小视频 | 韩国和日本免费不卡在线 | 国产精品涩涩涩视频网站 | 不卡一区二区高清观看视频 | 大香伊人久久精品一区二区 | xxx日本hd| 国产毛片A级久久久不卡精品 | 巨胸美女狂喷奶水www网麻豆 | 欧美 日韩 亚洲 在线 | 欧美激情一区二区三区四区 |