c# - Getting primary key from the database -
i created method traverses data returned primary key in repeat structure following error occurs, can not implicitly convert type "system.attribute" "bool"
using system; using system.collections.generic; using system.componentmodel; using system.data.sqlclient; using system.linq; using system.reflection; using system.web; update private void setself(cliente entity) { foreach (propertyinfo pro in entity.gettype().getproperties()) { if (this.gettype().getproperty(pro.name).getcustomattribute(typeof(dataobjectfieldattribute != null)) this.gettype().getproperty(pro.name).setvalue(this, pro.getvalue(entity)); } }
because line: this.gettype().getproperty(pro.name).getcustomattribute(typeof(dataobjectfieldattribute)
return system.attribute
, if
looking bool
.
don't want add check ?
if (this.gettype().getproperty(pro.name).getcustomattribute(typeof(dataobjectfieldattribute) != null){ }
Comments
Post a Comment