asp.net - Concat without blank in C# Linq -
i concatenating different address fields in linq query 1 address merge.
public static ilist getofferlist() { using (var objentity = new dbcontext()) { string[] listcategoryid = categoryid.split(','); return (from tbl.offermaster select new { primaryid = om.offerid, address = om.streetaddress + " ," + om.city + " ," + om.state + " ," + om.country + " ," + om.zipcode, }).tolist(); } }
currently fields like
address=fákafen 11 ,reykjavik , ,iceland ,108,
or
address: " , , , ,",;
i want
address=fákafen 11 ,reykjavik ,iceland ,108
means blank fields not required.
i this.
address = string.join(" ," (new string[] {om.streetaddress, om.city, om.state, om.country, om.zipcode}) .where(x=> !string.isnullorempty(x)));
Comments
Post a Comment