Hello everyone, I tried to bind a grid to an Entity having an Entity field. When I remove the entity field from the grid, it works fine. When I add it I get the following error although I have overridden the ToString of the reference entity to display meaningful data:

SerializationContext is required. Use SerializationScope to set it.

What is SerializationContext and what is SerializationScope? How can they be used in general and specially to solve this problem ?

Thanks in advance.

asked Oct 05 '10 at 03:35

msameer's gravatar image

msameer
29559

edited Oct 05 '10 at 05:38

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

I replaced the comment by answer.

(Oct 08 '10 at 03:12) Alex Yakunin Alex%20Yakunin's gravatar image

One Answer:

This error indicates there was a serialization attempt somewhere, but DO enables serialization only when SerializationContext is active.

As far as I can judge, your issue can't be related to serialization. So I'd like to see the stack trace to find out what really happens there.

answered Oct 08 '10 at 03:12

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

This error occurs only with DevExpress ASP.Net Quantum Grid (ASPxGridView). Microsoft ASP.Net's GridView binds fine. However, DevExpress grid also binds fine with classes that does not inherit from Entity (POCO). I will send the stack trace to support email.

(Oct 11 '10 at 10:36) msameer msameer's gravatar image

The mail message is received, we'll investigate the issue soon.

(Oct 11 '10 at 12:29) Dmitri Maximov Dmitri%20Maximov's gravatar image

I've looked up the stack trace. ASPxGridView really tries to serialize the data rows, possibly to:

  • Cache the data @ HTTP session (to avoid query re-execution?)
  • Cache the data @ ViewState (the same reason).

And definitely not to:

  • Send the data to the client (regular serialization won't help here, they'd use JSON serializer or something similar).
(Oct 11 '10 at 12:51) Alex Yakunin Alex%20Yakunin's gravatar image

Possible solutions:

1) Find out how to disable this behavior. I don't see much reasons for caching anything by grid itself. Logically, this must happen in lower layers (e.g. DAL). DevExpress designs their components for usability in typical & simple cases, so they added this feature (content caching) to grid.

If you'll really need to get some queries cached, we'll implement this API @ DO leve. Caching APIs is one of top-priority features for the next release.

(Oct 11 '10 at 12:54) Alex Yakunin Alex%20Yakunin's gravatar image

2) If you need grid's caching, you must convert the result to DTOs before passing it to grid (i.e. add .Select(item => new MyDdo { ProperyX = item.PropertyX, ... })). This result will be still queryable, i.e. grid will be able to use IQueryable API to filter, sort and group it. If your DTOs will be serializable, grid will be able to cache them.

(Oct 11 '10 at 12:54) Alex Yakunin Alex%20Yakunin's gravatar image

You are absolutely right. The grid has a property called EnableRowsCache. When I set it to false it worked fine. Thank you very much.

(Oct 12 '10 at 03:33) msameer msameer's gravatar image

Good then ;)

(Oct 12 '10 at 03:37) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA