分类:
ASP.NET
一对多
建立主表可读可写属性并使用Association特性进行关联
[Association("采购订单明细")]
[XafDisplayName("采购订单")]
public PurchaseOrder PurchaseOrder
{
get { return _purchaseOrder;}
set {SetPropertyValue(nameof(PurchaseOrder), ref _purchaseOrder, value);}
}
建立从表
[DevExpress.Xpo.Aggregated]//聚合型
[Association("采购订单明细")]
[XafDisplayName("采购订单")]
public XPCollection<OrderDetails> OrderDetails
{
get { GetCollection<OrderDetails>("OrderDetails");}
}
一对一
在角色与用户关联
Userinfo user = null;
public Userinfo User
{
get { return user; }
set
{
if (user == value) return;
Userinfo userinfo = user;
User = value;
if (IsLoading) return;
if (userinfo != null && userinfo.Role == this)
userinfo.Role = null;
if (user != null)
user.Role = this;
OnChanged(nameof(Role));
}
}
在用户与角色关联
Roleinfo role = null;
public Roleinfo Role
{
get { return role; }
set
{
if (role == value)return;
Roleinfo roleinfo = role;
role = value;
if (IsLoading) return;
if (roleinfo != null && roleinfo.User == this)
roleinfo.User = null;
if (role != null)
role.User = this;
OnChanged(nameof(Role));
}
}
多对多
[Association("Userinfo")]
public XPCollection<Userinfo> Userinfo
{
get { return GetCollection<Userinfo>(nameof(Userinfo)); }
}
[Association("Userinfo")]
public XPCollection<Roleinfo> Roleinfo
{
get { return GetCollection<Roleinfo>(nameof(Roleinfo)); }
}评价
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256
50010702506256
欢迎加群交流技术