Problem with change transient property

3 posts, 0 answers
  1. Nelson
    Nelson avatar
    62 posts
    Member since:
    Apr 2011

    Posted 31 Aug 2011 Link to this post

    Hi telerik,

    In my application, I have this transient in my model.

    [Telerik.OpenAccess.Transient()]
    private bool _seleccionado;
     
    [FieldAlias("_seleccionado")]
    public bool Seleccionado
    {
        get { return _seleccionado; }
        set { _seleccionado = value; }
    }


    The goal is, user send one notification with some files attached.

    When the user change the Seleccionado property that is a transient of "Anexos" table and try save the notification in database, there is an error, because ORM detects that "Anexos" tables was changed.

    So the user can´t save the notification, because the state of transient was changed and try submit all, notifications and attachments
    This happens because I did that in my code to save the notification:

    AppGlobais.Globais.ContextoSGA.SubmitChanges(SubmitCompleted, null);

    The "ContextoSGA" is the context of all model, and when I SubmitChanges, all pendent changes will be submited too. And the problem.

    I´m not sure if you can undersand. If yes, how I can solve the problem?

    Use different Contexts?

    Thanks



  2. Nelson
    Nelson avatar
    62 posts
    Member since:
    Apr 2011

    Posted 01 Sep 2011 Link to this post

    I don't know if I was very clear in my first post...

    Trying to describe the thing, it should come like this:

    I have these 3 tables in a relational database: "Notifications", "Attachments" and the relational table that connects the two previous ones, named "NoticationAttachments". An "Attachment" is inserted first, within the application, and can be used in several "Notifications".

    The main goal is to keep track of the attachments sent in each notification.

    So, in a Silverlight application, when a new Notification is created, the user should be able to select some attachments that he wants to send among the notification. In order to facilitate my UI approach I've created a transient Property wich I've added (in the Attachment's Entity) to the ORM Entity generated code (as posted in this first thread intervention). That transient property is boolean and is called "Seleccionado" (wich means selected in portuguese) and I was using it in order to MVVM bind it to the Telerik's GridView checkbox column that points wich Attachment's are to be associated with the new notification.

    The problem is that when the transient "Seleccionado" Property is changed, my Model Context detects changes on those attached selected entities and tries to submit changes among the new created notification... How can I avoid this?

    I don't know if has any influence in the reported problem but the "Attachments" object has a byte[] property:

    private byte[] _Conteudo;
         [Column("CONTEUDO", OpenAccessType = OpenAccessType.Blob, IsNullable = true, SqlType = "BLOB")]
         [Storage("_Conteudo")]
         public virtual byte[] ConteudoProp
         {
             get
             {
                 return this._Conteudo;
             }
             set
             {
                 this._Conteudo = value;
             }
         }

  3. DevCraft banner
  4. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 05 Sep 2011 Link to this post

    Hi Nelson,

     You said in your previous post that OpenAccess tries to submit the attachment object when the transient property is changed. What do you mean my submit in this case? Is it trying go INSERT it, even though the object exists, or is it generating an UPDATE statement. And also, is the generated statement failing or is it just inserting unnecessary data in the database? We really look forward towards resolving this problem but, we will require this bit of more information from your side so we can give you the best solution for the scenario.

    Greetings,
    Zoran
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

Back to Top