how o nest country state city and save the data and fetch it
how to create database for city state country
what format should be used to save this
and how to show it in mvc site
you don’t nest these nesting is used on something like user with profile
if you would use nesting you would only have 1 table cities with nested country and state but that would be kinda wrong.
i’ll give you a little example on product / category
public class Product { public ObjectId Id { get; set; } public string ProductName { get; set; } public decimal Price { get; set; } public ObjectId Category { get; set; } }
public class Category { public ObjectId Id { get; set; } public string CategoryName { get; set; } }
that’s a very simple example without the use of nesting for relations. i have another example where i use nesting in my relations. it’s used for my custom security.
public class User { public ObjectId Id { get; set; } public string UserName { get; set; } public string Email { get; set; } public string Password { get; set; } //public bool PasswordChanged //{ // get; // set; //} public Profile Profile { get; set; } public IList<ObjectId> Roles { get; set; } }
public class Role { public ObjectId Id { get; set; } public string Name { get; set; } public string Description { get; set; } public IList<RolePermission> Permissions { get; set; } }
public class Permission { public ObjectId Id { get; set; } public string Name { get; set; } public string Description { get; set; } }
public class RolePermission { public ObjectId Permission { get; set; } public int Level { get; set; } }
it’s a little more advanced but it gives a basic idea on how you have to do the relations.