public void ComponentMappingDemo()
{
//show how " /> 亚洲精品久久久久69影院,20岁αsrian男同志免费,有码 亚洲 制服 国产 在线

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

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

主站蜘蛛池模板: 3a丝袜论坛 | 少妇被阴内射XXXB少妇BB | 玩弄放荡人妻一区二区三区 | 青草久久精品亚洲综合专区 | 久久国产精品高清一区二区三区 | 国产高清超清在线播放 | 不知火舞vs精子 | 久久青青草原精品国产软件 | 日日噜噜噜夜夜爽爽狠狠图片 | 好看AV中文字幕在线观看 | 麻豆精品传媒卡一卡二传媒短视频 | 国产亚洲精品久久久久久无码网站 | 久久国产36精品色熟妇 | 校花娇喘呻吟校长陈若雪视频 | 国产超碰人人爱被IOS解锁 | 国产免费人成在线视频视频 | 欧美成a人片免费看久久 | 色婷婷综合久久久中文字幕 | 久久国产av偷拍在线 | 一本二卡三卡四卡乱码麻豆 | 小箩莉奶水四溅小说 | 亚洲欧美日本久久综合网站 | 国产视频成人 | 青青草国产精品久久 | 久久精品电影久久电影大全 | 99久久精品国内 | 日夜啪啪一区二区三区 | 少妇高潮惨叫久久久久久电影 | 久久国产高清字幕中文 | 久久精品国产免费中文 | swag合集120部 | 欧美三级黄色大片 | 亚洲日本欧美产综合在线 | 伊人久久中文 | 三级貂蝉艳史 在线观看 | qvod伦理片| 精品含羞草免费视频观看 | 前后灌满白浆护士 | 女的把腿张开男的往里面插 | 成人亚洲乱码在线 | 乐乐亚洲精品综合影院 |