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

Transient parameter

2 Answers 163 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vincent
Top achievements
Rank 1
Vincent asked on 01 Apr 2009, 11:59 AM
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 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 02 Apr 2009, 07:07 AM
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.
0
Brian Womack
Top achievements
Rank 2
answered on 15 Jun 2010, 08:32 PM
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(); 
    } 
 

Tags
General Discussions
Asked by
Vincent
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Brian Womack
Top achievements
Rank 2
Share this question
or