/// <summary> /// Returns full graph of single BusinessObject of table that satisfies the given <paramref name="id"/> or null if no such element is found. /// </summary> /// <typeparam name="TBusinessEntity">The type of BusinessObject of source table.</typeparam> /// <param name="id">Id of the BusinessObject.</param> /// <returns>BusinessObject the satisfy the <paramref name="id"/>.</returns> /// <exception cref="RepositoryException">When an error on the database level is occurred and couldn't be recovered.</exception> public TBusinessEntity SingleOrDefaultWithGraph <TBusinessEntity>(int id) where TBusinessEntity : class, new() { try { using (ShoppingListContext context = new ShoppingListContext()) { var primaryKeyPredicate = CreatePredicate <TBusinessEntity>(context, id); return(context.LoadAggregate(primaryKeyPredicate)); } } catch (Exception ex) { throw ThrowHelper.ReThrow <TBusinessEntity>(ex); } }