You are mixing the "type" and the "instance"
In your code, entityType is a type.
You probably have a variable like entityInstance that references an instance
of entityType, and the "as" operator should be applied to this variable:
IPersistent p = entityInstance as IPersistent;
Bruno
"Joe" <jb*******@noemail.noemail> a écrit dans le message de news:
%2****************@TK2MSFTNGP15.phx.gbl...
entityType implements IPersistent and does get into the if statement but p
is always null.
Type t = entityType.GetInterface(typeof(IPersistent).Name);
if (t != null)
{
IPersistent p = entityType as IPersistent;
// p Is always null.
}
-Joe