Sam
Sam

Reputation: 14596

breezejs: the new EntityErrorsException

I'm very interested in using the new EntityErrorsException that came with today's release. But the way my colleague implemented the server-side logic might be an issue.

In the webAPI controller, we use our own contextProvider, which inherits from breeze's EFContextProvider. See code below:

 public class SepaContextProvider : EFContextProvider<CompanyName.BLL.BLDirectDebitContext>
 {
    public MyContextProvider() : base() { }
 }

As you can see, the generic parameter is a BLDirectDebitContext, which inherits from a DirectDebitContext class defined in the data-access layer:

 public class DirectDebitContext : DbContext{
 }

This way, the entities are validated in the BLDirectDebitContext class by overriding ValidateEntity() so that if this code is called from a desktop application (that don't use webAPI or even breeze), the validation logic does not have to be re-written.

Ideally, we could create EFEntityError objects here and throw a EntityErrorsException. But that would mean referencing breeze.webapi dll in our business layer, which does not sound so good considering the number of dependencies.

Would it not make more sense to split the breeze.webapi dll into different dll's ? Or is it our approach that does not make any sense ?

Upvotes: 1

Views: 250

Answers (1)

Jay Traband
Jay Traband

Reputation: 17052

We are planning to refactor Breeze.WebApi into at least two or three dll's in the near future. (Sorry no exact date yet). One that includes the core .NET generic code ( with substantially fewer dependencies) and the other that is Entity Framework specific. We plan to release an NHibernate specific dll at the same time, in parallel to the Entity Framework version.

This will, of course, be a breaking change which is why we are trying to get everything organized properly so that we don't have to do this again. Ideally, the conversion from the current structure to the new one will be fairly easy for any Breeze consumers.

On a slightly related issue, did you notice that you can also use standard .NET DataAnnotation Validation attributes as well as the EntityErrorsException. The two mechanisms result in exactly the same client side experience.

Upvotes: 2

Related Questions