开发者

Class diagrams to show relation between classes?

Are class diagrams in visual studio supposed to show relation between classes, for eg. 1 : many.

public class User
{
    public string UserId { get; set; }
    开发者_Go百科public List<Role> Roles { get; set; }
}

public class Role {
    public int RoleId {get; set;}
    public User User {get; set;}
    public string UserId {get; set; }
}


Edit:
To clarify.. Class diagram generally isn't supposed to show relations (1:n, m:n etc.) because those relations are for database tables (entities). Classic class diagram is more suited for analysis and design, so it shows associations instead of relations.

Original answer:
Yes you can show 'relations', but you wont see any numbers afaik. It has its own way of showing. Numbers are shown in Entity Framework model for example.

How to show associations:
Move classes into diagram, and then right click on property Roles and pick Show as collection association.


If you want to show more advanced associations here is an addin for Visual studio from CodePlex.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜