There are two linq queries to MySql DbContext:
var letter1 = (from l in dbContext.letters_incoming
where l.LetterText.Trim() == "simple letter text".Trim()
select l).FirstOrDefault();
var letter2 = dbContext.letters_incoming.Where(new Func<ModelLetterIncoming, bool>(l => {
string name = l.LetterText;
if (name == "simple letter text")
return true;
else return false;
})).FirstOrDefault();
First query returns null, but second returns correct value. Is it may be caused by whitespaces in my Where condition?
the problem was in MySqlConnectionStringBuilder, I added
mySqlConnectionStringBuilder.CharacterSet = "utf8";
and it works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.