Exemple #1
0
        // DELETE api/values/5
        public dynamic Delete(int id)
        {
            DemoDb db     = new DemoDb();
            int    result = db.Database.ExecuteSqlCommand("delete from tasks where id=" + id);

            return(Json(new { type = result, mess = "" }));
        }
Exemple #2
0
        // POST api/values
        public dynamic Post(Task model)
        {
            DemoDb db = new DemoDb();

            db.Tasks.Add(model);
            db.SaveChanges();
            return(Json(new { type = model.id, mess = "" }));
        }
Exemple #3
0
        // GET api/values
        public dynamic GetList()
        {
            DemoDb  db     = new DemoDb();
            dynamic result = new ExpandoObject();

            result.expertInfoEducation = db.Tasks.ToList();
            return(result);
        }
Exemple #4
0
 void createdemo()
 {
     try
     {
         ViewBase.ApplicationObject = _applicationObject;
         DemoDb.Create();
     }
     catch (Exception e1)
     {
         ViewBase.ApplicationObject.StatusBar.Clear();
         LoggingHelper.HandleException(e1);
     }
 }
Exemple #5
0
        // GET api/values/5
        public dynamic Get(int id)
        {
            DemoDb db = new DemoDb();

            return(db.Tasks.FirstOrDefault(c => c.id == id));
        }
        static void Main(string[] args)
        {
            DemoDb db = new DemoDb();

            db.Execute(@"CREATE TABLE dictionary(
                           id INTEGER PRIMARY KEY AUTOINCREMENT,
                           title VARCHAR(256),
                           description TEXT
                        )
                        ;");

            Console.WriteLine("Table created");
            Console.WriteLine();

            int affectedRows = db.Execute("INSERT INTO dictionary(title, description) VALUES(@0, @1)",
                                                           "Java",
                                                           @"Java is a programming language originally developed by
                                                           James Gosling at Sun Microsystems (which is now a subsidiary
                                                           of Oracle Corporation) and released in 1995 as a core component
                                                           of Sun Microsystems' Java platform. The language derives much of
                                                           its syntax from C and C++ but has a simpler object model and fewer
                                                           low-level facilities.");

            Console.WriteLine("Inserted {0} rows", affectedRows);

            affectedRows = db.Execute("INSERT INTO dictionary(title, description) VALUES(@0, @1)", "Ruby", @"A dynamic, open source programming language with a focus on simplicity and productivity.");

            Console.WriteLine("Inserted {0} rows", affectedRows);

            affectedRows = db.Execute("INSERT INTO dictionary(title, description) VALUES(@0, @1)", "C#", @"C# (pronounced 'see sharp') is a multi-paradigm programming language encompassing
                                                imperative, declarative, functional, generic, object-oriented (class-based),
                                                and component-oriented programming disciplines.
                                                It was developed by Microsoft within the .NET initiative and later approved as a standard by
                                                Ecma (ECMA-334) and ISO (ISO/IEC 23270). ");

            Console.WriteLine("Inserted {0} rows", affectedRows);
            Console.WriteLine();
            Console.WriteLine("Dictionary:");
            Console.WriteLine("Id\tTitle\tDescription");

            var res = db.Query("SELECT * FROM dictionary");

            foreach (var r in res)
            {
                Console.WriteLine("{0}\t{1}\t...", r.id, r.title);
            }

            var c = db.Query("SELECT COUNT(*) AS Count FROM dictionary");

            Console.WriteLine("Count of record is {0}", c[0].Count);

            Console.WriteLine();
            Console.WriteLine("Finding Ruby Programming language");
            Console.WriteLine("Id\tTitle\tDescription");

            var ruby = db.Query("SELECT * FROM dictionary WHERE title = @0", "Ruby");
            foreach (var r in ruby)
            {
                Console.WriteLine("{0}\t{1}\t...", r.id, r.title);
            }

            Console.ReadKey();
        }