I seperate my data access in an Assemble( just ADO.NET things)
when i call BeginSave like bellow
Client.BeginSave((s,o) => {
if(o.Error==null
)
Client = o.NewObject
as MyProj.Business.Client.Client
;
there is an error happening says:
Type 'MyProj.DataAccess.Client.ClientDAO' in Assembly 'MyProj.DataAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
please help me, Thanks
Probably because your BO has a field where it is holding a reference to your ClientDAO object. I'd remove the field, you normally wouldn't need to keep the DAOs around outside of the DP_xyz methods (those should also be the only places your code uses the ClientDAO object).
Yes, you are right, i have a field of ClientDAO in my BusinessObject.
What if there are other reasons that i must keep my DataAccess in a seperate assemble, how to resolve it? Thanks!
I create the DataAccess instance in DP_xxx to resolve this. but i 'm not clear if this is the correct way.
Thanks!
Sorry, I'm not sure I understand what you're asking. Are you asking what if you had to have a reference to your DAO outside of the data portal methods? Or something else?
The DAO object fields should have the NonSeralilaized and NotUndoable attributes so that it will not be part of serialization or undo operations.
You may also look at the MEF samples for Repository and ObjectFactory data access in http:\\cslacontrib.codeplex.com to show a possible way of injecting the data access classes into BO's.
Copyright (c) Marimer LLC