c# - How to check an item already exist in mongo db and linq -


        var database = connection.testdb;         bool isexists = false;         var collection = database.getcollection<technolgy>("technology");          var query1 = collection.findall().setfields(fields<technolgy>.include(  x => x.name));                                                                                        var companycount = (from c in query1 select c).tolist();         foreach (var item in companycount)         {             isuserexists = (from t in companycount t.name.equals(name) select t).singleordefault() == null ? false : true;             if (isexists == true)             {                 return isexists;             }         }           return isexists; 

i know question asked can't find proper answer.my problem case sensitive search. ex. in database there field called technology in ,say audio , video saved.if query term audio , video query return true(isexists).but if query term audio , video returns false.how make query case insensitive

finally find own.

    var query = query.matches("name",  bsonregularexpression.create(new regex(model.name, regexoptions.ignorecase)));                 //var query1 = query.eq("name", model.name);                 var entity = database.getcollection<technology>(technology).findone(query);                  if (entity == null)                 {                   } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -