http://community.devexpress.com/forums/p/60725/205569.aspx
http://www1.devexpress.com/Support/Center/p/B39252.aspx
代码:
[DefaultClassOptions]
public class Master : XPCustomObject
{
public Master(Session session)
: base(session)
{
// This constructor is used when an object is loaded from a persistent storage.
// Do not place any code here or place it only when the IsLoading property is false:
// if (!IsLoading){
// It is now OK to place your initialization code here.
// }
// or as an alternative, move your initialization code into the AfterConstruction method.
}
public override void AfterConstruction()
{
base.AfterConstruction();
// Place here your initialization code.
}
private string _MasterName;
public string MasterName
{
get
{
return _MasterName;
}
set
{
SetPropertyValue("MasterName", ref _MasterName, value);
}
}
[Association("Master-Details")]
public XPCollection<Detail> Details
{
get
{
return GetCollection<Detail>("Details");
}
}
private MasterPrimaryKey _Key;
[Key,Persistent,Browsable(false)]
public MasterPrimaryKey Key
{
get
{
return _Key;
}
set
{
SetPropertyValue("Key", ref _Key, value);
}
}
[NonPersistent]
public string Key1
{
get { return Key.Key1; }
set
{
_Key.Key1 = value;
}
}
[NonPersistent]
public string Key2
{
get { return Key.Key2; }
set
{
_Key.Key2 = value;
}
}
}
public struct MasterPrimaryKey
{
[Persistent]
public string Key1;
[Persistent]
public string Key2;
}
public class Detail : XPCustomObject
{
public Detail(Session session)
: base(session)
{
// This constructor is used when an object is loaded from a persistent storage.
// Do not place any code here or place it only when the IsLoading property is false:
// if (!IsLoading){
// It is now OK to place your initialization code here.
// }
// or as an alternative, move your initialization code into the AfterConstruction method.
}
public override void AfterConstruction()
{
base.AfterConstruction();
// Place here your initialization code.
}
private int _ID;
[Key(AutoGenerate = true)]
public int ID
{
get
{
return _ID;
}
set
{
SetPropertyValue("ID", ref _ID, value);
}
}
private string _DetailName;
public string DetailName
{
get
{
return _DetailName;
}
set
{
SetPropertyValue("DetailName", ref _DetailName, value);
}
}
private Master _Master;
[Association("Master-Details")]
public Master Master
{
get
{
return _Master;
}
set
{
SetPropertyValue("Master", ref _Master, value);
}
}
}
public class Master : XPCustomObject
{
public Master(Session session)
: base(session)
{
// This constructor is used when an object is loaded from a persistent storage.
// Do not place any code here or place it only when the IsLoading property is false:
// if (!IsLoading){
// It is now OK to place your initialization code here.
// }
// or as an alternative, move your initialization code into the AfterConstruction method.
}
public override void AfterConstruction()
{
base.AfterConstruction();
// Place here your initialization code.
}
private string _MasterName;
public string MasterName
{
get
{
return _MasterName;
}
set
{
SetPropertyValue("MasterName", ref _MasterName, value);
}
}
[Association("Master-Details")]
public XPCollection<Detail> Details
{
get
{
return GetCollection<Detail>("Details");
}
}
private MasterPrimaryKey _Key;
[Key,Persistent,Browsable(false)]
public MasterPrimaryKey Key
{
get
{
return _Key;
}
set
{
SetPropertyValue("Key", ref _Key, value);
}
}
[NonPersistent]
public string Key1
{
get { return Key.Key1; }
set
{
_Key.Key1 = value;
}
}
[NonPersistent]
public string Key2
{
get { return Key.Key2; }
set
{
_Key.Key2 = value;
}
}
}
public struct MasterPrimaryKey
{
[Persistent]
public string Key1;
[Persistent]
public string Key2;
}
public class Detail : XPCustomObject
{
public Detail(Session session)
: base(session)
{
// This constructor is used when an object is loaded from a persistent storage.
// Do not place any code here or place it only when the IsLoading property is false:
// if (!IsLoading){
// It is now OK to place your initialization code here.
// }
// or as an alternative, move your initialization code into the AfterConstruction method.
}
public override void AfterConstruction()
{
base.AfterConstruction();
// Place here your initialization code.
}
private int _ID;
[Key(AutoGenerate = true)]
public int ID
{
get
{
return _ID;
}
set
{
SetPropertyValue("ID", ref _ID, value);
}
}
private string _DetailName;
public string DetailName
{
get
{
return _DetailName;
}
set
{
SetPropertyValue("DetailName", ref _DetailName, value);
}
}
private Master _Master;
[Association("Master-Details")]
public Master Master
{
get
{
return _Master;
}
set
{
SetPropertyValue("Master", ref _Master, value);
}
}
}
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/