c# - linq check if matches null or selected item -
i checking see if items match whats in mssql db. using linq update records. know how can check if item equal d_0_2 or if equal null/empty. how go doing this?
below existing code, partially works. failing due null/empty
if (updateproduct.studioid == convert.toint32(d_0_2.selectedvalue)) { } else { updateproduct.studioid = convert.toint32(d_0_2.selectedvalue);}
thanks in advance.
string value = d_0_2.selectedvalue.tostring(); // if selectedvalue empty or null? if (!string.isnullorempty(value)) return; // if product null? if (updateproduct != null) return; if (updateproduct.studioid != null && updateproduct.studioid == convert.toint32(value)) { // have product , id equal d_0_2.selectedvalue } else { // studioid not equal to d_0_2.selectedvalue updateproduct.studioid = convert.toint32(value); }
Comments
Post a Comment