Transient parameter

Thread is closed for posting
3 posts, 0 answers
  1. Vincent
    Vincent avatar
    1 posts
    Member since:
    Nov 2008

    Posted 01 Apr 2009 Link to this post

    Hi,

    I'm trying the new version of Open Access (Telerik_OpenAccess_ORM_2009_1_311_trial) and I created the SofiaCarRental example. Everything works fine.

    Now I'm trying to query some table of our database and I get the following error:

    {"PC parameter 0 is transient: Entities.ContactPerson: Entities.ContactPerson"}    Telerik.OpenAccess.OpenAccessException {Telerik.OpenAccess.Exceptions.InvalidOperationException}

    The following code works fine:
        var getPersons = from persons in newScope.Extent<ContactPerson>()
                               where persons.Username == person.Username && persons.Password == "secret"
                               select persons;

    The following code goes wrong:
        var getPersons = from persons in newScope.Extent<ContactPerson>()
                               where persons.Username == person.Username && persons.Password == person.Password
                               select persons;

    I don't get it because the person.Password returns a string.

    Could you please help me out, I spent a few hours on this problem but I can't get it fixed.

    Regards,
    Vincent Otterloo
  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 02 Apr 2009 Link to this post

    Hi Vincent,

    The query you are executing looks like a valid one. Could you send us a sample project where this behavior is demonstrated so we can dig a bit deeper into the problem and in that case provide you with a decent solution.


    Kind regards,
    Zoran
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Brian Womack
    Brian Womack avatar
    4 posts
    Member since:
    Nov 2008

    Posted 15 Jun 2010 Link to this post

    I banged my head on the wall for a better part of a day on the same problem in ORM version 2010.1.610.  It happens when you have a string property with only a 'get', which depends upon a transient field.  If you use mc.valStr in the LINQ expression below, you get the PC Parameter 0 transient error.  The code below works around the problem by creating a string temporary, mc_valStr.

    I do have a 'SetTransient' function that I can call if the validity check fails (i.e. if _transient_val < 0 then call SetTransient).  This is a very good idea to maintain data integrity, but does not solve the problem.

    [Telerik.OpenAccess.Transient()] 
    private int transient_val; 
     
    private string valStr; 
    [Telerik.OpenAccess.FieldAlias("valStr")] 
    public string ValStr 
        get 
        { 
             if (_transient_val >= 0) return valStr = _transient_val.ToString(); 
             else return null
         } 
     
    public static MyClass Find(IObjectScope scope, MyClass mc) 
        if (mc == nullreturn null
        else 
        { 
            string mc_valStr = mc.valStr; 
            return (from d in scope.Extent<MyClass>() 
                    where 
                    d.valStr != null && d.valStr.Equals(mc_valStr, StringComparison.OrdinalIgnoreCase) 
                    select d).SingleOrDefault(); 
        } 
     

Back to Top