This question is locked. New answers and comments are not allowed.
Hi, I have a rlinq Domain file and have a domainservice linked to it for RIA services but have a few questions about how to achieve certain things. Say my OpenAccessDomainService.generated.cs file looks like this
I also have a file called OpenAccessDomainService.cs so I can provide addtional functions to RIA without having to worry about these getting wiped when the other file is regenerated and this also sets up the DB Connection for me.
So for my Questions...
1. As you can see from the code I have added a WriteDBLog function within your auto generated callback method. This is not ideal as that class could get overwirtten due to the nature of a auto generated class. So is there a way of overriding the calback methods open access creates so that I can place additional code for delete, insert etc.. action in the OpenAccessDomainService.cs. I know I could just delete the method in the autogenerated class and add it to the other class but is there another way.
2. Also because I'm trying to read a property from the object being deleted I'm getting the error : It is not allowed to read or to write an instance marked for deletion. I know when I used to use the old ObjectScope way you could set property that allowed you to do this but can not seem to find out how you do it when using domain services.
3. When I add a new table in the DB and updated my rlinq file how can I get my domain service to auto create the methods. At the moment I'm editing the OpenAccessDomainService.tt file and adding in the table name, then when I compile the methods get created and that entity will now be available to RIA. Is there a more automated OA way of doing this.
Thanks
namespace
CSE.DA.DomainService
{
[EnableClientAccess()]
public
partial
class
CSENETDomainService : OpenAccessDomainService<CSEEntitiesModel>
{
public
CSENETDomainService() :
base
()
{
}
public
IQueryable<Am_asset_field> GetAm_asset_fields()
{
return
this
.DataContext.Am_asset_fields;
}
public
void
DeleteAm_asset_fields(Am_asset_field am_asset_field)
{
// This is a callback method. The actual Delete is performed internally.
WriteDBLog(
"Delete"
, User,am_asset_field.Name);
}
}}
namespace
CSE.DA.DomainService
{
public
partial
class
CSENETDomainService
{
}
protected
override
CSEEntitiesModel CreateDataContext()
{
return
new
CSEEntitiesModel(DBConnection.DBConnectionString, DBConnection.backend, DBConnection.metadataSource);
}
public
IQueryable<Am_asset_field> GetAm_asset_fields(
int
id)
{
return
this
.DataContext.Am_asset_fields.Where(p=> p.Asset_field_id==id);
}
}
So for my Questions...
1. As you can see from the code I have added a WriteDBLog function within your auto generated callback method. This is not ideal as that class could get overwirtten due to the nature of a auto generated class. So is there a way of overriding the calback methods open access creates so that I can place additional code for delete, insert etc.. action in the OpenAccessDomainService.cs. I know I could just delete the method in the autogenerated class and add it to the other class but is there another way.
2. Also because I'm trying to read a property from the object being deleted I'm getting the error : It is not allowed to read or to write an instance marked for deletion. I know when I used to use the old ObjectScope way you could set property that allowed you to do this but can not seem to find out how you do it when using domain services.
3. When I add a new table in the DB and updated my rlinq file how can I get my domain service to auto create the methods. At the moment I'm editing the OpenAccessDomainService.tt file and adding in the table name, then when I compile the methods get created and that entity will now be available to RIA. Is there a more automated OA way of doing this.
Thanks