Example #1
0
        static void Main(string[] args)
        {
            string connectionString = "Data Source = (local);Initial Catalog = CleverDb;Integrated Security = True;MultipleActiveResultSets = True";

            CleverDbContext db = new CleverDbContext(connectionString);

            var obj = new {
                name       = "Насос",
                parentId   = 95,
                attributes = new {
                    марка         = "Bosh",
                    мощность      = 95.3,
                    ДатаУстановки = DateTime.Now
                }
            };
            string stringified = Json.Encode(obj);
            var    clever      = CleverObjectService.GetCleverObjectFromJson(stringified);

            //insert operation
            CleverObject inserted = db.Insert(clever);

            Console.WriteLine(inserted.Id);

            //get operation
            CleverObject found = db.FindById(inserted.Id);

            //get subtree operation
            string json = db.GetSubTreeForTheNode(166);

            Console.WriteLine("done");
            Console.ReadKey();
        }
Example #2
0
        public object GetSubtree(int id)
        {
            string          connectionString = ConfigurationManager.ConnectionStrings["defaultConnection"].ConnectionString;
            CleverDbContext db = new CleverDbContext(connectionString);

            try
            {
                return(Json(db.GetSubTreeForTheNode(id)));
            }
            catch (Exception exp)
            {
                return(Request.CreateResponse <dynamic>(HttpStatusCode.InternalServerError,
                                                        new
                {
                    Exception = exp.GetType().Name.ToString(),
                    Message = exp.Message
                }));
            }
        }