Ejemplo n.º 1
0
        public static async void HashFromDB(ConcurrentDictionary <int, byte> CashDic)
        //use concurrent dictionary instead of hashset
        {
            using (ModelForDb ModelDb = new ModelForDb())
            {
                var result = await(from person in ModelDb.Persons where (person.RequestType % 2) == 0 select person.RequestType).ToListAsync();
                var dic    = result.ToDictionary(x => x, y => default(byte));
                CashDic = new ConcurrentDictionary <int, byte>(dic);

                WriteLine(CashDic.Keys);
            }
        }
Ejemplo n.º 2
0
 public void SendToDB(RootRequest request)
 {
     using (ModelForDb ModelDb = new ModelForDb())
     {
         string NewXml    = XmlString(request);
         person NewPerson = new person {
             Surname = request.Surname, Name = request.Name, Patronymic = request.Patronymic, BirthDay = request.BirthDay, RequestType = request.RequestType, Sex = request.Sex, XMLString = NewXml
         };
         ModelDb.Persons.Add(NewPerson);
         ModelDb.SaveChanges();
         logger.Info("Data sended to DB, Guid = ", Guid.NewGuid());
     }
 }