CRUD Operations

4 posts, 0 answers
  1. Carlos
    Carlos avatar
    50 posts
    Member since:
    Feb 2011

    Posted 11 May 2011 Link to this post

    Hi there,

    I'm implementing a silverlight application on wich I use Telerik's ORM.

    On my generated Context

            public IQueryable<FormasContacto> GetFormasContactos()
            {
                return this.DataContext.FormasContactos;
            }      
            public void DeleteFormasContactos(FormasContacto formasContacto)
            {
                // This is a callback method. The actual Delete is performed internally.
            }

            public void UpdateFormasContactos(FormasContacto formasContacto)
            {
                if (formasContacto != null)
                {
                    bool i = this.DataContext.FormasContactos.Any(a =>
                        a.DesignacaoProp.ToUpper().Trim() == formasContacto.DesignacaoProp.ToUpper().Trim() &&
                        a.IdProp != formasContacto.IdProp);
                }
            }

            public void InsertFormasContactos(FormasContacto formasContacto)
            {
                // This is a callback method. The actual Insert is performed internally.
            }


    If I intended to do some validations ("Server side") before inserting, updating or deleting a "FormasContacto" how should I proceed?

    Note: in method "UpdateFormasContactos" I was checking if there was another "FormasContacto" entity with the same "DesignacaoProp"... and if  I wanted to cancel the update action if the result of my "custom" validation is true or false?

    Another question is, if I could cancel any insert, update or delete after doing some validations on the referred methos, how could I inform the silverlight application of what happened? Throw Exceptions?

    Thanks in advance
    Carlos Sampaio
  2. Carlos
    Carlos avatar
    50 posts
    Member since:
    Feb 2011

    Posted 12 May 2011 Link to this post

    I was really needing some help here!

    Where is "public void UpdateFormasContactos(FormasContacto formasContacto)" called? And when?
  3. DevCraft banner
  4. Carlos
    Carlos avatar
    50 posts
    Member since:
    Feb 2011

    Posted 12 May 2011 Link to this post

    I'm going insane... I just want a way to get in my silverlight app a message (in an exception or other way) so I can inform the user that some entity could not be update for a customized reason.
  5. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 16 May 2011 Link to this post

    Hi Carlos,

    If you would like to stick to the void method then yes, the only way of notifying the silverlight application would be by throwing an exception. You can also modify the method to return some sort of a flag that will notify you if the operation has passed or not (be it boolean or something else that makes sense for you)
     
    Regards,
    Petar
    the Telerik team
    Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
Back to Top