示例#1
0
        public void TestGetOne()
        {
            var sampleDataModel = new SampleDataModel().Get(new QueryModel()
            {
                Parameters = new Dictionary <string, object>()
                {
                    { "IntData2", 1 },
                },
            }).First();

            Debug.WriteLine(sampleDataModel.ToString());
            Assert.IsNotNull(sampleDataModel);
        }
示例#2
0
        public void AddGetUpdateInsert()
        {
            //SampleDataModel sampleDataModel2;
            SampleDataModel sampleDataModel3;
            SampleDataModel sampleDataModel = new SampleDataModel()
            {
                TextData1  = "my new TextData",
                IntData2   = 3,
                CustomEnum = MyCustomEnum.Foo,
            };

            ///
            ///
            ///  TODO: Upsert Disabled
            ///
            ///


            // so let's get it by TextData1 then by IntData2

            // sampleDataModel.Upsert<SampleDataModel>();


            // pass in name value pairs of the columns and search values (using new instance for testing convenience)
            // use TextData1
            //sampleDataModel2 = SampleDataModel.Get(new QueryModel()
            //{
            //    Parameters = new Dictionary<string, object>()
            //    {
            //            { "TextData1",  "my new TextData" },
            //    },
            //});

            //Debug.WriteLine(sampleDataModel2.ToString());
            //Assert.IsNotNull(sampleDataModel2);



            // use int
            sampleDataModel3 = new SampleDataModel().Get(new QueryModel()
            {
                Parameters = new Dictionary <string, object>()
                {
                    { "IntData2", 1 },
                },
            }).First();
            Debug.WriteLine(sampleDataModel3.ToString());
            Assert.IsNotNull(sampleDataModel3);

            // Disabling Upsert for now
            // change a value
            //sampleDataModel2.IntData2 = 10;
            //sampleDataModel2.Upsert<SampleDataModel>();

            //// fetch back into #3 by id to see if it changed
            //sampleDataModel3 = SampleDataModel.Get(new QueryModel()
            //{
            //    Parameters = new Dictionary<string, object>()
            //{
            //    { "Id", sampleDataModel2.Id }
            //},
            //});
            //Debug.WriteLine(sampleDataModel3.ToString());

            //Assert.AreEqual(sampleDataModel3.IntData2, sampleDataModel2.IntData2);

            //// add a few (haven't handled bulk add yet but that's easy too. So for now, one at a time
            //sampleDataModel = new SampleDataModel()
            //{
            //    TextData1 = "my new TextData2",
            //    IntData2 = 55,
            //    CustomEnum = MyCustomEnum.Foo,
            //};
            //sampleDataModel.Upsert<SampleDataModel>();

            //sampleDataModel = new SampleDataModel()
            //{
            //    TextData1 = "my new TextData3",
            //    IntData2 = 55,
            //    CustomEnum = MyCustomEnum.Foo,
            //};
            //sampleDataModel.Upsert<SampleDataModel>();

            //// now let's get them all

            //List<SampleDataModel> result = SampleDataModel.GetList();

            //foreach (var sample in result)
            //    Debug.WriteLine(sample.ToString());

            //// now lets just get the ones with intData = 3
            //result = SampleDataModel.GetList(new QueryModel()
            //{
            //    Parameters = new Dictionary<string, object>()
            //    {
            //        {"IntData2",55}
            //    },
            //});

            //foreach (var sample in result)
            //    Debug.WriteLine(sample.ToString());
        }