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

OpenAccess Error: Value cannot be null. Parameter name: con

4 Answers 198 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.
NemFontos
Top achievements
Rank 1
NemFontos asked on 22 Mar 2009, 12:25 AM

OA throws this exception (I think this is some reflection and constructor-related problem) when I build that code:

public class Persisted  
{  
    protected Guid id;  
    protected int version;  
}  
 
[Serializable]  
[Persistent(IdentityField = "_id", VersionField = "_version")]  
public class A : Persisted  
{  
    private string name;  
    ....  

I want to create a base class for my DAL classes (to call a method to fill the lazy fields before serializing). 

How can I do that?

Thanx!

4 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 23 Mar 2009, 08:12 AM
Hi NemFontos,
You have to mark the base class also as persistent and map it 'horizontal' in the forward mapping dialog.

We will make the exception a lĂ­ttle more readable.

Greetings,
Jan Blessenohl
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
NemFontos
Top achievements
Rank 1
answered on 23 Mar 2009, 12:52 PM

Hi Jan,

thank you, but I don't need to persist the base class, I'm just need it to provide common functionality and the "version" field.

As you see on the other thread (telerik.com/community/forums/orm/general-discussions/objectnetworkattacher-vs-datacontractserializer.aspx) I have problem with the lazy "version" value.

To avoid lazy loading, I can define the "version"  field in my base class and call it before serializing:

[OnSerializing]  
protected void BeforeSerialize(StreamingContext ctx)  
{  
     int tmp = Version;  

Sorry if I'm too lame and can't understand something very trivial.

Thanx in advance,

NemFontos

0
Accepted
Jan Blessenohl
Telerik team
answered on 23 Mar 2009, 02:50 PM
Hi NemFontos,
We can only store data in fields of an persistent class. If the base class is not marked as persistent we will not store the content of the id and version field. In your case the id and version field is not stored, which produces the weird exception.

Greetings,
Jan Blessenohl
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
NemFontos
Top achievements
Rank 1
answered on 23 Mar 2009, 04:53 PM
Thank you!
Tags
General Discussions
Asked by
NemFontos
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
NemFontos
Top achievements
Rank 1
Share this question
or