15,901,205 members
Home / Discussions / Algorithms

# Algorithms

 Re: Guess A Word If Number Of Character Matches Are Given OriginalGriff20-Jun-21 21:01 OriginalGriff 20-Jun-21 21:01
 What are the in-order and post-order traversals of the following tree? priyamtheone20-May-21 5:02 priyamtheone 20-May-21 5:02
 Re: What are the in-order and post-order traversals of the following tree? harold aptroot20-May-21 7:08 harold aptroot 20-May-21 7:08
 Re: What are the in-order and post-order traversals of the following tree? priyamtheone20-May-21 9:37 priyamtheone 20-May-21 9:37
 Re: What are the in-order and post-order traversals of the following tree? harold aptroot20-May-21 9:48 harold aptroot 20-May-21 9:48
 Algorithm to rank items lower if they already appear higher in another category Member 117824613-Mar-21 19:41 Member 11782461 3-Mar-21 19:41
 Re: Algorithm to rank items lower if they already appear higher in another category Ralf Meier9-Mar-21 5:55 Ralf Meier 9-Mar-21 5:55
 Saving Hierarchical (Treeview) object Iteratively with parent and child in C# Md NasirUddin24-Feb-21 5:35 Md NasirUddin 24-Feb-21 5:35
 `I have database table object which is:` C# ```[Table("TreeViewDb")] public class TreeViewDb { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public int ParentId { get; set; } public string Name { get; set; } }``` `And I have a view model whcih is :` C# ```
public class TreeView { 	public TreeView() 	{ 		Children = new List(); 	}  	public int Id { get; set; } 	public int ParentId { get; set; } 	public string Name { get; set; }  	// children 	public List Children { get; set; } }```  Now I need to save TreeView to the database. During save children or children under children to the nth Level. But my below method only goes to level 3. How can I go to nth Level to save child and parent objects with recursive way?  C#   	   ```public bool SaveOrUpdateTreeView(TreeView viewModel) { 	// Level 1 	var parentModel = new TreeViewDb 	{ 		Id = viewModel.Id, 		ParentId = viewModel.ParentId, 		Name = viewModel.Name 	};  	// Save or update object and return primary key 	var parentId = _dataRepository.SaveOrUpdateTreeView(parentModel);  	// Level 2 	foreach (var child in viewModel.Children) 	{ 		var childModel = new TreeViewDb 		{ 			Id = viewModel.Id, 			ParentId = parentId, // Parent Primary Key 			Name = viewModel.Name 		};  		// Save or update object and return primary key 		var childId = _dataRepository.SaveOrUpdateTreeView(childModel);  		// Level 3 		foreach (var grandChild in child.Children) 		{ 			var grandChildModel = new TreeViewDb 			{ 				Id = viewModel.Id, 				ParentId = childId, // Child Primary Key 				Name = viewModel.Name 			};  			_dataRepository.SaveOrUpdateTreeView(grandChildModel); 		}  		return true; 	}  	return true; }```
 Re: Saving Hierarchical (Treeview) object Iteratively with parent and child in C# Gerry Schmitz24-Feb-21 6:28 Gerry Schmitz 24-Feb-21 6:28
 Looking for "card playing" algorithm David Crow4-Jan-21 9:30 David Crow 4-Jan-21 9:30
 Re: Looking for "card playing" algorithm Ralf Meier4-Jan-21 9:43 Ralf Meier 4-Jan-21 9:43
 Re: Looking for "card playing" algorithm Peter_in_27804-Jan-21 11:15 Peter_in_2780 4-Jan-21 11:15
 Re: Looking for "card playing" algorithm jsc426-Jan-21 4:33 jsc42 6-Jan-21 4:33
 Re: Looking for "card playing" algorithm Peter_in_27806-Jan-21 12:46 Peter_in_2780 6-Jan-21 12:46
 Re: Looking for "card playing" algorithm Gerry Schmitz5-Jan-21 3:27 Gerry Schmitz 5-Jan-21 3:27
 formulate an algorithm Member 1502086714-Dec-20 6:59 Member 15020867 14-Dec-20 6:59
 Re: formulate an algorithm Greg Utas14-Dec-20 7:31 Greg Utas 14-Dec-20 7:31
 Re: formulate an algorithm Gerry Schmitz14-Dec-20 11:37 Gerry Schmitz 14-Dec-20 11:37
 Re: formulate an algorithm Patrice T14-Dec-20 12:38 Patrice T 14-Dec-20 12:38
 Re: formulate an algorithm Member 1525570320-Jun-21 20:01 Member 15255703 20-Jun-21 20:01
 Problem in c language Member 150165689-Dec-20 3:16 Member 15016568 9-Dec-20 3:16
 Re: Problem in c language Richard Deeming9-Dec-20 3:43 Richard Deeming 9-Dec-20 3:43
 Last Visit: 31-Dec-99 18:00     Last Update: 19-May-24 5:23 Refresh ᐊ Prev1...78910111213141516 Next ᐅ