3
Comment rechercher un enregistrement par clé primaire, mais retourner la valeur null si elle n'existe pas?TryFindByPrimaryKey dans Castle ActiveRecord
public static T FindByPrimaryKeyOrDefault(object id)
{
try
{
return ActiveRecordMediator<T>.FindByPrimaryKey(id);
}
catch (NotFoundException)
{
return null;
}
}