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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -