Home > Net >  Convert value to Lowercase in Linq
Convert value to Lowercase in Linq

Time:02-10

I am getting a value from Database and Map to another value, for example

This is My Database Table:

empVaue navValue
each EA
pack of 6 6P
bag BG
box BX

I wanted to map this means

in my form I get EACH or each so I want to use this mapping table and if item.PurchaseUOM.Value is each or EACH first convert it to lowercase and then compare in C#:

 each or EACH=> EA

I tried this line, but in the linq like that I used ToLower() it is breaking:

       using (var db = new Context())
        {            
            List<string>navUOMs = new List<string>();
            foreach (var item in order.orderItems)
            {
                var navUOM = db.Get<EmpToNavUOMMap>().FirstOrDefault(u => u.EmpUOM == item.PurchaseUOM.Value.ToLower());
                item.PurchaseUOM.Value = navUOM.NavUOM;              
            }
            return order;
        }        

CodePudding user response:

  •  Tags:  
  • Related