I believe the
as
operator internally performs a cast in a try/catch block which, although effective, is probably not the most efficient. If you're looking for better efficiency, perhaps the code should follow the pattern
if (model is IPrimaryRelatable) {
((IPrimaryRelatable)model).RelateToSource(sourceObject, env);
}
if (model is ISecondaryRelatable) {
((ISecondaryRelatable)model).CreateSecondaryRelationships(data, env);
}