CodeSmith主键外外键

本文详细解析了数据库中表与表之间的关系,通过foreach循环遍历主键,明确主表和子表的区分,并提供了判断主表与子表的方法。同时,介绍了如何获取关系中的主表第一个主键和子表的第一个外键。

1.         foreach(TableKeySchema primaryKey in SourceTable.PrimaryKeys)

 

这里的primaryKey 其实是表与表之间的关系名称,primaryKey.Name就是它的关系名称。

primaryKey.ForeignKeyTable.Name 就是子表的表名了。

 

primaryKey.PrimaryKeyMemberColumns[0] 就是这个关系中的主表的第一个主键。

 

primaryKey.ForeignKeyMemberColumns[0] 就是这个关系中的子表的第一个外键。

 

2.         如何判断是否主表和子表:

SourceTable.ForeignKeys.Count 如果为0则是主表,非0的都是外键表


原创作品出自努力偷懒,转载请说明文章出处http://blog.csdn.net/kfarvid或 http://www.cnblogs.com/kfarvid/

CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)CodeSmith+注册码(注册机)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值