This is a migrated thread and some comments may be shown as answers.

CRUD Operations

3 Answers 89 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Carlos
Top achievements
Rank 2
Carlos asked on 11 May 2011, 06:40 PM
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

3 Answers, 1 is accepted

Sort by
0
Carlos
Top achievements
Rank 2
answered on 12 May 2011, 12:01 PM
I was really needing some help here!

Where is "public void UpdateFormasContactos(FormasContacto formasContacto)" called? And when?
0
Carlos
Top achievements
Rank 2
answered on 12 May 2011, 06:32 PM
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.
0
PetarP
Telerik team
answered on 16 May 2011, 04:17 PM
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.
Tags
Getting Started
Asked by
Carlos
Top achievements
Rank 2
Answers by
Carlos
Top achievements
Rank 2
PetarP
Telerik team
Share this question
or