hi there
i am trying to build up a string containing the values of fields in a linq to sql object. the thing is, i only want to grab the fields that are not null
i am sure there is a way to do this. can anyone enlighten me?
mylinqdatacontext dc = new mylinqdatacontext;
StringBuilder sb = new StringBuilder();
mylinqtype item = (from x in dc.mylinqtypes where x.id.equals(1)).single();
var props = typeof(mylinqtype).GetProperties();
foreach(PropertyInfo p in props){
if(item... != null){
sb.append(p.name + " :" + item[p].value; //or some such i dont really know
}
}
any help much appreciated
i have tried
object theValue = p.getgetmethod().invoke(item, null);
but it threw a System.Reflection.TargetException thanks
nat