c# - How to check if a state object is of type ICollection -


i use nhibernate interceptor compare values of old state , current state of entity properties of properties of type icollection guide me how check if object of type icollection

this code

    public void onpostupdate(nhibernate.event.postupdateevent @event)     {         var entitytoaudit = @event.entity iauditable;         string path = path.combine(appdomain.currentdomain.basedirectory, "auditlog.txt");         using (streamwriter sw = file.appendtext(path))         {             (int = 0; < @event.oldstate.length; i++)             {                 string propertyname = @event.persister.propertynames[i];                 if (@event.oldstate[i] != null)                 {                     if (!@event.oldstate[i].equals(@event.state[i]))                     {                         sw.writeline("the value of "+ propertyname + " has been changed " + @event.oldstate[i] + " " + @event.state[i]);                     }                 }                 else                 {                     if (@event.state[i] != null)                     {                         sw.writeline("the value of "+ propertyname + " has been changed being empty " + @event.state[i]);                     }                 }             }         }     } 

you have more 1 options this, use is or use as null checking:

if (obj icollection){     //your logic } 

or, if need object icollection later on, recommend use as:

var icoll = obj icollection if (icoll != null){     //use icoll     //icoll.something(); } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -