hierarchy

Hierarchical Data in MySql

烂漫一生 提交于 2019-11-27 06:10:50
问题 I have a table with parent child relation I want help on recursive query Table structure roleId, roleName, parentId 1 Admin 0 2 Backup Admin 1 3 Office User 1 0 4 User 1 3 5 User 2 3 6 Office User 2 0 7 Off User 1 6 I am trying to make recursive query but I am not able to do please suggest me how should I query database e.g. Admin -- Backup Admin Office User 1 -- User 1 -- User 2 Office User 2 -- Off User 1 回答1: As pointed out above this isn't truly recursive but if you know how many steps

Build JSON Hierarchy from Structured Data

三世轮回 提交于 2019-11-27 06:03:00
问题 C# | .NET 4.5 | Entity Framework 5 I have data coming back from a SQL Query in the form of ID,ParentID,Name. I'd like to take that data and parse it into a Hierarchical JSON string. So far it seems to be much more of a daunting task than it should be. Since I'm using Entity the data comes back nicely to me as an IEnumerable. Now I believe I just need some form of recursion, but I'm not quite sure where to start. Any help is appreciated. Data Returns as id parentId name 1 1 TopLoc 2 1 Loc1 3 1

SQL Server OPENJSON read nested json

廉价感情. 提交于 2019-11-27 05:08:48
问题 I have some json that I would like to parse in SQL Server 2016. There is a hierarchy structure of Projects->Structures->Properties. I would like to write a query that parses the whole hierarchy but I don't want to specify any elements by index number ie I don't want to do anything like this: openjson (@json, '$[0]') or openjson (@json, '$.structures[0]') I had this idea that I could read the values of the top level project objects along with the json string that represents the structures

Rendering a hierarchy using LINQ?

一个人想着一个人 提交于 2019-11-27 03:36:28
问题 Let say we have a class Category { ID, Name, ParentID } and a List 1, 'Item 1', 0 2, 'Item 2', 0 3, 'Item 3', 0 4, 'Item 1.1', 1 5, 'Item 3.1', 3 6, 'Item 1.1.1', 4 7, 'Item 2.1', 2 Can we using LINQ to render a tree like: Item 1 Item 1.1 Item 1.1.1 Item 2 Item 2.1 Item 3 Item 3.1 Any help is appreciated! 回答1: Here's the "LINQ-only" version: Func<int, int, string[]> build = null; build = (p, n) => { return (from x in categories where x.ParentID == p from y in new[] { "".PadLeft(n)+ x.Name }

Warning: Attempt to present * on * whose view is not in the window hierarchy - swift

偶尔善良 提交于 2019-11-27 03:05:57
I'm trying to present a ViewController if there is any saved data in the data model. But I get the following error: Warning: Attempt to present * on *whose view is not in the window hierarchy" Relevant code: override func viewDidLoad() { super.viewDidLoad() loginButton.backgroundColor = UIColor.orangeColor() var request = NSFetchRequest(entityName: "UserData") request.returnsObjectsAsFaults = false var appDel:AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate) var context:NSManagedObjectContext = appDel.managedObjectContext! var results:NSArray = context

LINQ sort a flat list based on childorder

醉酒当歌 提交于 2019-11-27 02:36:13
问题 I am currently trying to figure out a good way to sort my elements with LINQ and C#, but I am kinda failing to do so. For the problem let assume you have the following Table ---TempTable ID (int) ParentID (int) Name (varchar) SortOrder (int) The ID and ParentID are related to each other and give me a self hierachical data structure. The root elements have a null in the ID Field. The SortOrder is only a portion of the whole table and based on the ParentID, so the elements that share the same

Make *ALL* Wordpress Categories use their Parent Category Template

我怕爱的太早我们不能终老 提交于 2019-11-27 01:10:23
问题 I want to change the default template hierarchy behavior, and force all subcategory level pages that don't have their own category template file to refer to their parent category template file. In my other post, Richard M. gave an excellent answer that solved the problem for an individual subcategory. Does anyone know how to abstract it? function myTemplateSelect() { if (is_category()) { if (is_category(get_cat_id('projects')) || cat_is_ancestor_of(get_cat_id('projects'), get_query_var('cat')

ASP.NET MVC 3 Treeview

馋奶兔 提交于 2019-11-27 00:39:20
问题 I need to display a Treeview in my MVC3 application. There will be a self referencing hierarchical table (Folders) and another table linked to it (Documents.) (So Folders can have N-subFolders and any folder/sub folder can have many documents.) I have looked into using third party vendors such as Telerik, DJME and MVC Controls Toolkit. While all nice packages, I'm uneasy about the licences, and since i'm new to MVC (and programming in general,) I find their documentation lacking to get the

Moving a git repository up one hierarchy level

六月ゝ 毕业季﹏ 提交于 2019-11-27 00:34:14
Git beginner question: I have a small private webproject which is versioned locally with msysgit. There is no exterior repository, as it's only for me, so i can bascially do whatever I want. I've had this set up in the project directory, ie in "webroot". Now a second directory had to be created, placed parallel to webroot. Let's call it assets. So structure is now as follows: \ project directory ----\webroot ----\assets I'd love to include this new directory in the git repository, so that I'd also version changes to files stored there, but of course I can't use "git add ../assets". Neither am

How to design a hierarchical role based access control system

半城伤御伤魂 提交于 2019-11-26 23:52:52
问题 Basic deal is, we have a custom built "kickstart" for our projects. For this we are looking at redoing the user control. I know there are a lot of questions out there about general rbac, but I cannot find any on hierarchical rbac? Our requirements are: Roles can be assigned to group permissions If the role does not have a permission entry then it is automatically denied A user can be given overriding permissions A users overriding permissions is either a grant or deny If a user is explicitly