This question is locked. New answers and comments are not allowed.
Does anyone know the best way to update an object that is being accessed at the ASP.NET page level through a BLL which in turn gets it from OA's datalayer? To complicate the question, how best should I handle setting a sub-object of the update object? So, if I have a Product object, and I have a subobject of Category type... i change the category to another one, usually I would just chang e the categoryID in the stored proc, but now it seems I have to get the whole object? (seems like a lot of round trips!)
Please comment on my whole updating process... it seems like a lot of manual setting of properties for nothing:
This is the test method at the page level:
This is the BLL method that updates.. as you can see, i am setting the values of the parameters again in the BLL because otherwise i get runtime-errors from OA.
Keeping in mind that the CRUD examples in the KB article that I read, are simplistic examples that do not pass the object to a BLL, and do not deal with sub-objects, is this the 'right' way to do it? Again, it seems like a heck of a lot of manual setting of properties.
Any help would be greatly appreciated!!
Please comment on my whole updating process... it seems like a lot of manual setting of properties for nothing:
This is the test method at the page level:
protected void cmdTest_Click(object sender, EventArgs e) |
{ |
JobRequirementParameter p = JobRequirementParameterUtility.GetByID(1); |
p.JobDemandItem = JobDemandItemUtility.GetByID(2);//I have to make a round trip to get the demand object?? |
p.JobRequirementItem = JobRequirementUtility.GetByID(1); // I have to make a roundtrip here too? |
p.Description = "sometext"; |
p.Code = "@code"; |
p.DataTypeID = 1; |
JobRequirementParameterUtility.Update(p); |
} |
This is the BLL method that updates.. as you can see, i am setting the values of the parameters again in the BLL because otherwise i get runtime-errors from OA.
public static bool Update(JobRequirementParameter c) |
{ |
using (IObjectScope scope = Scope.GetNewObjectScope()) |
{ |
scope.Transaction.Begin(); |
var b = (from cc in scope.Extent<JobRequirementParameter>() |
where cc.ParameterID == c.ParameterID |
select cc).Single(); |
if (b != null) |
{ |
JobRequirementParameter bn = (JobRequirementParameter)b; |
b.Code = c.Code; |
b.DataTypeID = c.DataTypeID; |
b.Description = c.Description; |
var demandItem = (from d in scope.Extent<JobDemandItem>() |
where d.DemandID==c.JobDemandItem.DemandID |
select d).SingleOrDefault(); //Another round trip?????? |
b.JobDemandItem = demandItem; |
//b.JobRequirementItem = c.JobRequirementItem; (commented out for now) |
b.Title = c.Title; |
scope.Transaction.Commit(); |
return true; |
} |
else |
{ |
return false; |
} |
} |
} |
Keeping in mind that the CRUD examples in the KB article that I read, are simplistic examples that do not pass the object to a BLL, and do not deal with sub-objects, is this the 'right' way to do it? Again, it seems like a heck of a lot of manual setting of properties.
Any help would be greatly appreciated!!