Пример #1
0
        private static void LoadDataInSQLServer(string filepath)
        {
            var businesses = File.ReadAllLines(filepath);
            var srv        = new ElasticSearchService();
            var cnt        = businesses.Length;

            foreach (var line in businesses)
            {
                if (line.Length > 150)
                {
                    continue;
                }
                var k = new Business {
                    Name = line.Trim(), Code = Util.TimeStampCode("BIZ")
                };
                _context.Businesses.Add(k);
                _context.SaveChanges();
                cnt--;
                Console.WriteLine("Remains: " + cnt);
                srv.IndexBusinessSync(k);
            }
        }