This project is read-only.

suggestion: add static method for New Instance of Model.

Sep 1, 2011 at 12:56 PM

I love the static methods that come built in like : 

  Dim UserObj as MyProject.Business.Objects.User = MyProject.Business.Objects.User.SelectUsingPK(1) 
  where i can get back an instanse with just one line of code. 
  It would be a great addition if each model class also had a static method ''NewInstance''
  which developer can call like this :

 Dim UserObj as MyProject.Business.Objects.User = MyProject.Business.Objects.User.NewInstance

behind the scenes this static method generated  will simply create and return a new instanse

        Dim UserCol = New MyProject.Business.Objects.UserCollection
        Dim UserObj = UserCol.NewItem
        Return UserObj
  so in just one line of code a new instance will be delivered without the hassle of instantiating the collection classes
  what do you think ?

Sep 8, 2011 at 1:25 AM

The reason this is not done is because of data integrity. In the NHDAL version the object cannot be added back to the collection until its non-null constraints are met. This makes it a bit difficult to create and add a new object to the collection. You know your own business rules and objects and need to set certain fields to values before the actual add will work. If a non-null field is not set before adding to the collection an exception is thrown.