score:2

Accepted answer
    private bool validatelinkedfield(string fieldname)
    {
        //loop through the "levels" (e.g. order / customer / name) validating that the fields/properties all exist
        type currenttype = resulttype;
        foreach (string currentlevel in dequalifyfieldname(fieldname, resulttype))
        {
            memberinfo match = (memberinfo)currenttype.getfield(currentlevel) ?? currenttype.getproperty(currentlevel);
            if (match == null) return false;
            currenttype = match.membertype == membertypes.property ? ((propertyinfo)match).propertytype
                                                                   : ((fieldinfo)match).fieldtype;
        }
        return true; //if we checked all levels and found matches, exit
    }

Related Query

More Query from same tag