XAF 如何:映射数据库视图到持久化类
How to: Map a Database View to a Persistent Class(如何:映射数据库视图到持久化类)http://documentation.devexpress.com/#Xaf/CustomDocument3281
http://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gifhttp://common.cnblogs.com/images/copycode.gif
首先创建一个结构体,结构体中的属性为要绑定的视图列
public struct MyViewKey
{
"Name")]
public string Name;
"PhoneCode")]
public string PhoneCode;
"Street")]
public string Street;
"City")]
public string City;
"FullAddress")]
public string FullAddress;
}
然后将这个结构体当成是Persistent类的KEY
"TestView")] //TestView为视图名
public class MyView : XPLiteObject {
public MyViewKey Key;
public string Name{ get { return Key.Name; } }
public string PhoneCode { get { return Key.PhoneCode; } }
public string Street { get { return Key.Street; } }
public string City { get { return Key.City; } }
public string FullAddress { get { return Key.FullAddress; } }
}
这样就完成了
用到的视图Sql:
SELECT dbo.Country.Name, dbo.Country.PhoneCode, dbo.Address.Street, dbo.Address.City,
dbo.Address.FullAddress
FROM dbo.Address INNER JOIN
dbo.Country ON dbo.Address.Country = dbo.Country.Oid
Address:
CREATE TABLE . (
(100) COLLATE Chinese_PRC_CI_AS NULL ,
(100) COLLATE Chinese_PRC_CI_AS NULL ,
(100) COLLATE Chinese_PRC_CI_AS NULL ,
(100) COLLATE Chinese_PRC_CI_AS NULL ,
(100) COLLATE Chinese_PRC_CI_AS NULL ,
[int] NULL ,
[int] NULL ,
[int] IDENTITY (1, 1) NOT NULL ,
[int] NULL
) ON
Country:
CREATE TABLE . (
[int] IDENTITY (1, 1) NOT NULL ,
(100) COLLATE Chinese_PRC_CI_AS NULL ,
(100) COLLATE Chinese_PRC_CI_AS NULL ,
[int] NULL ,
[int] NULL
) ON
GO
先收藏起来,以后慢慢学习。
页:
[1]