private void udg_OnGridLoad() { articles = StorageManager.Instance.CreateOrGet("Articles"); tags = StorageManager.Instance.CreateOrGet("Tags"); var ts = new Tag[3]; ts[0] = tags.AddEntity<Tag>(new Tag {Name = "news"}); ts[1] = tags.AddEntity<Tag>(new Tag {Name = "adv"}); ts[2] = tags.AddEntity<Tag>(new Tag {Name = "depth"}); for (int i = 0; i < 10; i++) { Article a = articles.AddEntity<Article>(new Article {Caption = "cap_" + i, Content = "content_" + i}); for (int j = 0; j <= i%3; j++) { a.Tags.AddJoint(ts[j].ObjectKey); } } articles.Link(); udg.Gv.DataSource = articles.GetEntities<Article>(); udg.Gv.CellClick += GvDetails_CellClick; }
public void OnLoad() { StorageManager.Instance.Initialize(new FileAdapter()); LoadResult rlt = StorageManager.Instance.Load(); if (!rlt.IsSuccessful) { EntityGroup users = StorageManager.Instance.CreateOrGet("Users"); EntityGroup roles = StorageManager.Instance.CreateOrGet("Roles"); EntityGroup articles = StorageManager.Instance.CreateOrGet("Articles"); EntityGroup tags = StorageManager.Instance.CreateOrGet("Tags"); UserRole admin = roles.AddEntity<UserRole>(new UserRole {RoleName = "Administrator"}); UserRole power = roles.AddEntity<UserRole>(new UserRole {RoleName = "PowerUser"}); for (int i = 0; i < 10; i++) { User u = users.AddEntity<User>(new User {Username = "******" + i, Password = "******"}); if (i%2 == 0) { u.RoleId = admin.ObjectKey; } else { u.RoleId = power.ObjectKey; } } var ts = new Tag[3]; ts[0] = tags.AddEntity<Tag>(new Tag {Name = "News"}); ts[1] = tags.AddEntity<Tag>(new Tag {Name = "SourceCode"}); ts[2] = tags.AddEntity<Tag>(new Tag {Name = "Advertisement"}); for (int i = 0; i < 10; i++) { Article a = articles.AddEntity<Article>(new Article {Caption = "title_" + i, Content = "content_" + i}); for (int j = 0; j <= i%3; j++) { a.Tags.AddJoint(ts[j]); } } } }