EnitityFramework is very slow to compare strings because create a nvarchar sqlparameter instead of varchar

后端 未结 3 1356
别跟我提以往
别跟我提以往 2020-12-11 23:55

I have this sample query:

context.BarcodeTipiDoc.AsQueryable().Where(d => d.Barcode.CompareTo(minBarcode) > 0);
         


        
3条回答
  •  时光说笑
    2020-12-12 00:16

    You can define the column as non-unicode in the context's OnModelCreating override:

    modelBuilder.Entity().Property(x => x.Barcode).IsUnicode(false);
    

提交回复
热议问题