Ejemplo n.º 1
0
        static private void cleanDatabase()
        {
            using (tag_qualityContext db = new tag_qualityContext())
            {
                db.Database.ExecuteSqlRaw("DROP TABLE IF EXISTS tag_combinations");
                db.Database.ExecuteSqlRaw("DROP TABLE IF EXISTS tag_combination_details");
                db.Database.ExecuteSqlRaw(@"CREATE TABLE public.tag_combinations
                    (
                        id bigint NOT NULL,
                        tag_id bigint NOT NULL,
                        country_id bigint NOT NULL,
                        tag_count bigint,
                        average_corros_tags double precision,
                        top_tags text[] COLLATE pg_catalog.""default"",
                        CONSTRAINT tag_combinations_pkey PRIMARY KEY (id)
                    )");

                db.Database.ExecuteSqlRaw(@"CREATE TABLE public.tag_combination_details
                    (
                        id bigint NOT NULL,
                        tc_id bigint,
                        tag_key text COLLATE pg_catalog.""default"",
                        count bigint,
                        percent double precision,
                        CONSTRAINT tag_combination_details_pkey PRIMARY KEY(id)
                    )
                    ");
            }
        }
Ejemplo n.º 2
0
        //Get All tags from DB, like amenity=cafe, amenity=fast_food, etc.
        static public List <TagsKeyValue> getAllTagsFromDB()
        {
            String get_all_tags          = @"select * from tags_key_value";
            List <TagsKeyValue> tagsList = new List <TagsKeyValue>();

            using (tag_qualityContext db = new tag_qualityContext())
            {
                tagsList = db.TagsKeyValues
                           .FromSqlRaw(get_all_tags)
                           .ToList();
            }
            return(tagsList);
        }
Ejemplo n.º 3
0
        //Get All countries from DB, like Sri Lankya, paraguay, etc.
        static public List <Country> getAllCountriesFromDB()
        {
            String         get_all_countries = @"select * from country where status=1";
            List <Country> CountryList       = new List <Country>();

            using (tag_qualityContext db = new tag_qualityContext())
            {
                CountryList = db.Countries
                              .FromSqlRaw(get_all_countries)
                              .ToList();
            }
            return(CountryList);
        }
Ejemplo n.º 4
0
        static private void insertTagCombinationDetailData(TagCombinationDetail tagCombinationDetail)
        {
            using (tag_qualityContext db = new tag_qualityContext())
            {
                db.Set <TagCombinationDetail>().Add(tagCombinationDetail);

                try
                {
                    int records = db.SaveChanges();
                    //Console.WriteLine("Saved {0} Tag Combination Detials to DB", records);
                }
                catch (DbUpdateException e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine(e.InnerException);
                }
            }
        }