예제 #1
0
        protected override void OnStart()
        {
            // Handle when your app starts
            List <Person> list;

            using (var db = new ClientNoSqlDB.DbInstance("test"))
            {
                db.Map <Person>().Automap(i => i.Id);
                db.Initialize();
                list = db.LoadAll <Person>().ToList();
                if (list != null && !list.Any())
                {
                    db.Save(new Person()
                    {
                        FirstName = "Ken", Id = 1, LastName = "Tucker"
                    },
                            new Person()
                    {
                        FirstName = "Tony", Id = 2, LastName = "Stark"
                    },
                            new Person()
                    {
                        FirstName = "John", Id = 3, LastName = "Papa"
                    });
                }

                list = db.LoadAll <Person>().ToList();
            }
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            List <Person> list;

            using (var db = new ClientNoSqlDB.DbInstance("testing"))
            {
                db.Map <Person>().Automap(i => i.Id);
                db.Initialize();
                list = db.LoadAll <Person>().ToList();
                if (list != null && !list.Any())
                {
                    db.Save(new Person()
                    {
                        FirstName = "Ken", Id = 1, LastName = "Tucker"
                    },
                            new Person()
                    {
                        FirstName = "Tony", Id = 2, LastName = "Stark"
                    },
                            new Person()
                    {
                        FirstName = "John", Id = 3, LastName = "Papa"
                    },
                            new Person()
                    {
                        FirstName = "Delete", Id = 4, LastName = "Me"
                    });
                }

                var item = db.LoadByKey <Person>(4);
                if (item != null)
                {
                    db.Delete <Person>(item);
                }
                list = db.LoadAll <Person>().ToList();
            }
            List <string> names = new List <string>();

            foreach (var p in list)
            {
                names.Add($"{p.FirstName} {p.LastName}");
            }
            items       = names.ToArray();
            ListAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, items);
            // Set our view from the "main" layout resource
            //SetContentView(Resource.Layout.Main);
        }
예제 #3
0
        public override void ViewDidLoad()
        {
            table = new UITableView(View.Bounds); // defaults to Plain style
            List <Person> list;

            using (var db = new ClientNoSqlDB.DbInstance("testing"))
            {
                db.Map <Person>().Automap(i => i.Id);
                db.Initialize();
                list = db.LoadAll <Person>().ToList();
                if (list != null && !list.Any())
                {
                    db.Save(new Person()
                    {
                        FirstName = "Ken", Id = 1, LastName = "Tucker"
                    },
                            new Person()
                    {
                        FirstName = "Tony", Id = 2, LastName = "Stark"
                    },
                            new Person()
                    {
                        FirstName = "John", Id = 3, LastName = "Papa"
                    },
                            new Person()
                    {
                        FirstName = "Delete", Id = 4, LastName = "Me"
                    });
                }

                var item = db.LoadByKey <Person>(4);
                if (item != null)
                {
                    db.Delete <Person>(item);
                }
                list = db.LoadAll <Person>().ToList();
            }
            List <string> names = new List <string>();

            foreach (var p in list)
            {
                names.Add($"{p.FirstName} {p.LastName}");
            }
            string[] tableItems = names.ToArray();
            table.Source = new TableSource(tableItems);
            Add(table);
        }
예제 #4
0
        static void Main(string[] args)
        {
            List <Person> list;

            using (var db = new ClientNoSqlDB.DbInstance("testing"))
            {
                db.Map <Person>().Automap(i => i.Id);
                db.Initialize();
                list = db.LoadAll <Person>().ToList();
                if (list != null && !list.Any())
                {
                    db.Save(new Person()
                    {
                        FirstName = "Ken", Id = 1, LastName = "Tucker"
                    },
                            new Person()
                    {
                        FirstName = "Tony", Id = 2, LastName = "Stark"
                    },
                            new Person()
                    {
                        FirstName = "John", Id = 3, LastName = "Papa"
                    },
                            new Person()
                    {
                        FirstName = "Delete", Id = 4, LastName = "Me"
                    });
                }
                var item = db.LoadByKey <Person>(4);
                if (item != null)
                {
                    db.Delete <Person>(item);
                }
                list = db.LoadAll <Person>().ToList();

                foreach (var p in list)
                {
                    Console.WriteLine($"{p.FirstName} {p.LastName}");
                }
            }
        }
예제 #5
0
        public MainPage()
        {
            InitializeComponent();
            List <Person> list;

            using (var db = new ClientNoSqlDB.DbInstance("testing"))
            {
                db.Map <Person>().Automap(i => i.Id);
                db.Initialize();
                list = db.LoadAll <Person>().ToList();
                if (list != null && !list.Any())
                {
                    db.Save(new Person()
                    {
                        FirstName = "Ken", Id = 1, LastName = "Tucker"
                    },
                            new Person()
                    {
                        FirstName = "Tony", Id = 2, LastName = "Stark"
                    },
                            new Person()
                    {
                        FirstName = "John", Id = 3, LastName = "Papa"
                    },
                            new Person()
                    {
                        FirstName = "Delete", Id = 4, LastName = "Me"
                    });
                }

                var item = db.LoadByKey <Person>(4);
                if (item != null)
                {
                    db.Delete <Person>(item);
                }
                list = db.LoadAll <Person>().ToList();
            }
            lstNames.ItemsSource = list;
        }