- Windows 7, 64 bits
- Visual Studio 2010, .NET Framework 4.0
- PostgreSQL 9.1
- Telerik OpenAccess Q2 2012 Free Edition
I change my plataform to:
- Windows 8, 64 bits
- Visual Studio 2012, .NET Framework 4.0
- PostgreSQL 9.1
- Telerik OpenAccess Q2 2012 SP2 Free Edition
Unable to cast object of type 'OpenAccessRuntime.Relational.RelationalNewObjectOID' to type 'System.Collections.ICollection'
there any way to solve this error?
thanks in advance and sorry for my bad English
12 Answers, 1 is accepted
This is a known bug which will be fixed with the next version. This only occurs if you create an object and assign a reference to the object, before the object is added to the context. If you add the reference on the object after your object is added to the context, then this error will not occur.
See the following script as example for your workaround:
// this will fail
var refrnce =
new
SomeOtherClass();
var obj =
new
SomeClass(){ Id = 123, Reference = refrnce };
ctx.Add(obj)
// will fail
// this will not fail
var obj =
new
SomeClass(){ Id = 123 };
ctx.Add(obj)
// will not fail
var refrnce =
new
SomeOtherClass();
obj.Reference = refrnce;
Please accept my apologies for any inconvenience caused.
I hope this information is helpful for you.
Feel free to ask if you have any other question.
All the best,
Ralph
the Telerik team
I am the same problem.I think it is a problem in OpenAccess.
If you have 1 class with releation 1:n
and in your code is like this:
Achitare.FmTipDocumente = model.FmTipuriDocumentes.Where(p => p.NumeScurt == "CHIT").FirstOrDefault();
Openaccess generate this error when you add this object to model.
One temporary solution for you is this:
Achitare.FkTipDocumente = (model.FmTipuriDocumentes.Where(p => p.NumeScurt == "CHIT").FirstOrDefault()).Pk;
Now we just wait for the next version.
as my code is somewhat complicated by the changes you pose I get another error.
The next version will have the needed bits to work with the approach you had before.
@Neagoe: Have you tried to set your references when your object is managed by the context? You shouldn't get an error then as described earlier.
Do come back if you need further assistance.
Ralph
the Telerik team
This error is killing us. Is there an internal build available with the fix in it?
ian
The bug is already fixed and will be available with the next internal build to be released soon. I will keep you updated once the internal build is released.
Please accept my apologies for the inconvenience caused so far.
Ralph
the Telerik team
The new build will be available soon. Most probably in a few days.
I will keep you updated as soon as the update is released.
Ralph
the Telerik team
same issue here: I have an object (let's say "order") with a classic foreing key reference (let's say "customer").
"customer" is a non nullable external reference.
I get the exception as soon as I add the "order" to the context using code below:
Order newOrder = new Order();
newOrder.Customer = GetCustomer("customerCode");
model.OpenAccessContext.add(newOrder);
We are in great hurry here ...
thanks
PS I noticed an inconsistency in the OrmModel (.rlinq) file. There's a non-nullable field that is actually missing from the actual Class and from the database table. Updating the model from the database doesn't fix that.
PPS NOW SOLVED
ok I got it.
FIRST I have to create the "order" object WITHOUT any reference to the CUSTOMER.
Then I have to add the ORDER to the Context
Then I have to load the CUSTOMER from the context
Then I have to add the ORDER to the CUSTOMERS.ORDERS collection
Probably I were missing the IsManaged property of the relation in the designer
the issue has been fixed with the latest internal build which is available for download since today.
I hope your issue has been solved.
Do come back if you have further questions.
Ralph
the Telerik team
I would suggest you to directly download the Q3 2012 release of OpenAccess ORM which is now available on our site. You can access it either by Your Account -> Manage Products -> Free Products -> OpenAccess ORM, or you can just go the OpenAccess homepage and download it from there.
Ivailo
the Telerik team