The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Collection edited event?

Last post 08-22-2008, 6:32 AM by rotep. 8 replies.
Sort Posts: Previous Next
  •  08-19-2008, 1:34 AM 10813

    Collection edited event?

    Hi Guys,

    i'm using ES combined with a Gantt tool. This Gantt tool is able to change the values of Entities in a Collection, because the collection is used as a datasource. Is there a way to catch an event in a esCollection that values in the collection have been changed? I need to save back the changes to the database immediately.

    Thanks

  •  08-19-2008, 4:42 AM 10814 in reply to 10813

    Re: Collection edited event?

    Have you looked into our INotify functionality, there is a check box on the Advanced tab and you can catch all of the property changed events. Or are you trying to catch Insert/Delete events?

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-19-2008, 5:21 AM 10815 in reply to 10814

    Re: Collection edited event?

    No I need to catch property changes only.

    The thing is that the datasource of the component is a collection, and the PropertyChange event is probably on the entities? Or can the entity notify it's parent collection?

  •  08-19-2008, 9:28 AM 10824 in reply to 10815

    Re: Collection edited event?

    Here is a link to INotifyPropertyChanged:

     http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(VS.80).aspx

     Here is a link to BindingList<T>

    http://msdn.microsoft.com/en-us/library/ms132679(VS.80).aspx

    INotifyPropertyChanged does work at the object or entity level and raises events when properties are changed (assuming that it is implemented properly). By cheching the checkbox (as suggested), it will be implemented for you.

    As far as changes related to a collection, you should use a datasource that raises ListChanged events. BindingList<T> can be used as a wrapper for other collections. Often, if the entities do not implement INotifyPropertyChanged, the collection won't raise ListChanged events if a property of an object has changed (I.e. sometimes without INotifyPropertyChanged, only adding or deleting entire records would raise the ListChanged event)

     

  •  08-20-2008, 6:05 AM 10839 in reply to 10824

    Re: Collection edited event?

    Thank you for clearing things out a little...

    Doesn't it involve a lot of time rewriting my generated collections (which i can use as datasources) to BindingList(of Entities), while keeping the same functionality as the original collections? (e.q. loading by query, or loadall functionality...)

  •  08-20-2008, 6:44 AM 10840 in reply to 10839

    Re: Collection edited event?

    I'm not sure this is really an ES issue is it? Isn't this more of just a binding thing?
    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  08-20-2008, 9:42 AM 10844 in reply to 10839

    Re: Collection edited event?

    > Doesn't it involve a lot of time rewriting my generated collections (which i can use as datasources) to BindingList(of Entities), while keeping the same functionality as the original collections? (e.q. loading by query, or loadall functionality...)First, I agree that

    First, I agree that this isn't an ES issue. It has to to do with .NET and the choices made by MS (Microsoft) as well as the choices made by each individual developer to accommodate the framework supplied by MS.

    I am just trying to help and to explain everything would certtainly take a great deal of time. However - personally - I don't think it takes that much time. Alternatively, you can use a BindingSource and use it's ResetItem method. See example here:

    http://www.dotnetspider.com/resources/2302-Binding-Source-Net.aspx

    Frankly, there are many ways to design an application. For example, I run my applications in N-Tiers where there is a client application (the client forms), a client manager controls all data requests and each form interacts with the manager via proxy stubs; the manager communicates via WCF to a service; the service process requests by deserializing the proxy stub objects and loading them into the generated classes and communicates various requests via WCF to the database or databases and/or other services. It is, obviously, more complicated than a basic description can provide.

     For me, having the generated output be BindingList(Of T) collections would make no sense because my service does not data bind at all, the client forms do and they interact with proxy stubs.

     I understand what you want: the generated output to be complete, but then I ask you this:

    How do you validate the entries made by your users?

    If you register with validating events on forms and add code to the form, then you are building form-by-form anyway and I don't understand the big deal.

    If you are trying to avoid duplication and speed up the design of forms as well as reduce future maintenance time - then you would use some form of Model/View/Controller design: I use my own version. It takes more time up front but reduces and simplifies the process over time. Within the controller/manager is where you design wrapper for your business objects so they bind appropriately as well as handle validation. To give an example: if you allow users to enter an email address and you decide to use RegEx check for a specific pattern to ensure the address is valid, you would have one place where that code is located. You then apply "rules" for each object and tell the object that XXX field needs to pass the "IsValidEmail" rule and supply a meessage for when it does not. In fact, you will likely have scenarios for multiple rules for a single field, let alone the whole object.

    Using a centralized approach, if the email address rule changes, you change one spot and all objects/forms applying the rule are updated. Using the form-by-form approach, you would have to manually correct every form.

    I suspect you might want to look into Model/View/Controller and other similar designs.

    There are a LOT of resources and VIDEOS regarding the subject.

    I can only say that I have tested many ORM tools and several licenses. I honestly believe that ES is the the best and the only one that works well in a N-Tier application. However, this is just one man's opinion.

     

  •  08-21-2008, 1:31 AM 10861 in reply to 10844

    Re: Collection edited event?

    Trevor, I really appreciate your efforts!

    I'm gonna have to look into some GOOD BindingSource / Databinding examples. I'll start with the one you provided, however I've been developing .NET websites for over 2 years now and I still don't have a good overview (lack of clear examples i guess, maybe i'm stupid). The problem is that I'm now developing a WinForms application and it's different again...

    I have some good experience building 3-tier applications, this application i'm building right now doesn't need the full blown layer separation. It just needs to be built quick and needs to function... I hope my choice for ES and the Gantt component will do just that.

    I was also sold immediately when I started testing ES, and when Gantt component support people told me that all the needed interfaces were implemented by the framework I thought it would fit nicely. However there are still some bumps which my lack of experience just can't fill instantly...

  •  08-22-2008, 6:32 AM 10872 in reply to 10861

    Re: Collection edited event?

    I'm trying to define a BindingSource in design time. The DataSource for the BindingSource needs to be a EntityCollection (EpPlanCollection) which is generated by ES.

     For the DataMember however I can only set related Collections (e.g. EpPlanCollectionByEppParent -> the Ep_Plan table has a recursive relation) because these are defined as properties. If i define my own property AllEpPlans which returns a EpPlanCollection it is not accepted as a DataMember for the DataSource.

    How should I define a datamember which loads the entities which I need in the DataSource?

View as RSS news feed in XML