What about bean-validation's date constraints and java.time? - bean-validation

Bean Validation comes with those built-ins #Past and #Future. According to the specification those constraints are only supporting those old Date and Calendar classes. What are my options for using those Bean Validation built-ins with java.time?

A better place for asking this question would be the beanvalidation-dev List. Fortunately I did recently:
Supporting new Java 8 data types seems to be a good candidate for
the next iteration of the Bean Validation spec. [..] However, in Hibenrate Validator
we already started the work on supporting Java 8, including the new date and time types.
Hibernate Validator 5.2 should make this functionality available, probably well before there will be a new spec version.
That will be the following options for you:
Wait for HV 5.2
Implement own validators and add these to the built-ins.
Use a third party library which supplies validators for those built-ins.
Disclaimer: I'm the author of that library.

Related

Good reference for all useful data annotations for Entity Framework (6+) models?

I have been unable to find a good reference for all useful data annotations that can be used on Entity Framework code-first models. I've found a Code First Data Annotations article and the System.ComponentModel.DataAnnotations Namespace reference and the System.ComponentModel.DataAnnotations.Schema Namespace reference but there are a few that can be used from the System.ComponentModel namespace (i.e. the commonly used DisplayName annotation) for your data model, but not all of them.
Is there a better reference for what is and is not useful for EF data model annotations? I think part of the answer also involves which annotations are actually used today by the default EF templates. I just wrote my own little extension that gets the Display(Description) annoations so I can use that in my HTML title tags (and thus by handy things like jQueryUI's tooltips) so I suppose it's possible to "use" a ton of annotations if you extract them yourself. But there are many used by EF to figure out your model schema, too. It's just really aggravating to bounce back and forth between the various references figuring out which annotations you can pick from. I should just quit whining and publish my own little cheat sheet huh :) But in the interests of DRY I'm hoping that already exists somewhere!
Actually there is no complete and updated reference for Last version of EF which cover all aspects of the Code first approach.You have to involve in couple of things such as text book on this issue or videos,but the best way I recommend you to do is,to decompile resources or assemblies in Visual studio and Resharper tools and try to figure out by codes.
Update:EF Code First Data Annotations are limited by count(about 16) and if you want to have more control over your Data Model creating you have to use EF Code First Fluent API way to do it.Here are some good references:
"Configuring/Mapping Properties and Types with the Fluent API"
"Entity Framework Tutorial"

does entity framework support User Defined Data Types?

I'm going to be starting work on a new application soon and was looking into using Entity Framework, however the database has User Defined Data Types, from looking online it seems like EF 4 does not support User Defined Data Types. Do anyone know if it is supported on EF5 or EF6? I'm not able to find anything online to say whether support was added in 5 or 6.
Yes, this is available in Entity Framework 6, but you'll need to become familiar with complex types.

validation with Entity framework and WPF/Silverlight or ASP.Net

In a wpf application using POCO classes with Entity framework, what is the best way to perform validation on data. I am aware of data annotations but if I am not compeltely wrong they are more used with ASP.Net MVC than WPF (i didnt find many examples with WPF). Earlier I was having my Domain classes implement the IDataErrorInfo interface but I wasnt sure if this was the correct approach. If I would want to share my EntityFramework classes at a later stage with say a silverlight application or an ASP.NET application what would be my best approach so that I can reuse my validation rules. (With ASP.net i believe my IDataErrorInfo way of handling errors would be useless?).I can find a lot of similar questions but not one that particularly meets my needs. It would be great if anyone can point me in the right direction
I have been using T4 templates on my domain model to generate the POCO classes and have been using these POCO class objects as business objects too
Out of the box, WPF Validation uses IDataErrorInfo and/or ValidationRule's on bindings. IDataErrorInfo being the partial classes that provide a way to tie in additional logic to make sure the value is valid (IE: The Person.Age property is between 1-100) and ValidationRule's being able to inspect the value before it is ever applied to the binding (IE: The Person.Age property is an integer at all). IDataErrorInfo is obviously only helpful when the value of a Binding gets updated with a compatible datatype, ValidationRule's are helpful in the event somebody types "Ten" instead of 10, in your Age textbox and the datatypes are not compatible.
IDataErrorInfo is reusable for all WPF/Silverlight/ASP.NET projects, (see: How to use IDataErrorInfo in ASP.NET)
Whereas ValidationRule's are to be used with Bindings and therefore not useful in a ASP.NET project. They could be considered the equivalent of Javascript validation.
In short, IDataErrorInfo is exactly what you're looking for and will provide the most reuse for those technologies.
IDataErrorInfo is not supported out-of-the box with EF validation. Annotations are used not only for validation but also can be used to define your model (e.g. Required, MaxLenght, StringLength attributes etc.). Out-of-the box you can use a few more mechanisms to validate your entities - by writing your own attribute by deriving from ValidationAttribute, by using CustomValidationAttribute or by implementing IValidatableObject. That's what EF supports out of the box. If neither of these works for you can replace built-in validation by overwriting DbContext.ValidateEntity() method and use any validation mechanism that works for you. A couple useful links: http://blogs.msdn.com/b/adonet/archive/2010/12/15/ef-feature-ctp5-validation.aspx
http://blogs.msdn.com/b/adonet/archive/2011/05/27/ef-4-1-validation.aspx

ASP.NET SPA with a legacy domain objects

Looking at the Single page application beta in the MVC 4 I don't see how I can use my legacy domain objects as the model. It seems to require that the model use the entity framework to using DbDataController to get the data etc.
I do not understand the entity framework so I am probably missing something.
How can I use my legacy domain (with it's own DAL) in the SPA of MVC 4?
This was answered by somebody else in an ASP.NET forum.
You won't be able to use anything other than EF if you want to use some of these RAD tools. However, SPA builds on top of MVC, so you should be able to build your own version rather easily. The important components would be building a DataController on top of ApiController and a js consumer for the service provided by your DataController. It's possible that if you were to format your models in the same format as the EF output (I think it's just OData) you could use upshot.js, as well and only have to implement a DataController to format your domain models.
I will add the following after working with it for a couple of days that you could, theoretically, use it if the following are handled/fixed by you and future versions of the SPA.
You can create a controller that inherits from System.Web.Http.Data.DataController (and maybe even ApiController). The objects it returns then must just have a property decorated with the System.ComponentModel.DataAnnotations.Key() attribute. I can get the views to work fine but some of the more advance features, like grouping, I am having problems with.
Readonly property will not be returned I guess because of a problem with the current JSON serializer used. Should be fixed.
Of course the entire object will be serialized which can be very problematic if your domain objects are complex with child objects. Especially if some of those objects have serialization issues of their own.
Related to the complex serialization the current JSON serializer cannot handle circular references in the domain objects referenced.
I have also run into problems getting update/deletes/inserts being posted back when using my own Controller that inherits from System.Web.Http.Data.DataController (the examples use DBDataController).

Can a custom class be used in the Conditions of a rule / policies?

I am getting started with Biztalk 2010 for the first time.
I looked at this article (http://www.codeproject.com/KB/biztalk/BRE.aspx) for making a custom action to fire against a condition, but it seems that properties are being used in actions, not conditions. Can an action reference a .NET method which accepts non-primitive types as parameters (e.g. custom classes etc)?
The BizTalk Rules Engine can deal with several types of facts, including plain-old CLR objects, both in condition evaluation as well as actions.
In order to test you policies, through, you will need to create a custom Fact Creator for the specific .Net classes you want to use.
When using .NET objects as facts, please, pay close attention to correctly implementing object identity with the help of the GetHashCode and Equals methods.

Resources