BLAZOR 6.0 Calling method on business object with different name other than Fetch #3170
-
Hello, Business Object Code: [Fetch]
private void GetEquipmentToAssign(Guid EquipmentID, [Inject] DataAccess.IEmployeeEquipmentDal dal)
{
var data = dal.GetEquipmentToAssign(EquipmentID);
using (BypassPropertyChecks)
Csla.Data.DataMapper.Map(data, this);
BusinessRules.CheckRules();
} Razor code: await vm.RefreshAsync(() => EmployeeEquipmentEditPortal.GetEquipmentToAssign(Guid.Parse(EquipmentID))); but when I try to call it from the razor page I get the following error: "IDataPortal' does not contain a definition for 'GetEquipmentToAssign' and no accessible extension method 'GetEquipmentToAssign' accepting a first argument of type 'IDataPortal' could be found (are you missing a using directive or an assembly reference?) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
On the client-side you are interacting with the client-side data portal, and it has specific method names you can't change. On the server-side, you get to name your server-side data portal operation methods as you choose, using the operation attributes so the data portal can identify which methods correspond to an operation. If you want customized names for things on the client, you should consider using a factory type. Form example: public class EmployeeEquipmentEditFactory
{
private IDataPortal<EmployeeEquipmentEdit> Portal { get; set; }
public EquipmentFactory(IDataPortal<EmployeeEquipmentEdit> portal)
{
// get data portal via dependency injection
Portal = portal;
}
public async Task<EmployeeEquipmentEdit> GetEquipmentToAssign(Guid equipmentId)
{
return await Portal.FetchAsync(Guid.Parse(equipmentId));
}
} You can inject this factory type instead of an |
Beta Was this translation helpful? Give feedback.
-
Hello @rockfordlhotka, I have a question about this that I still dont understand. Since we are not able to call methods with different names other than Fetch,Update,Delete, etc.. directly from Razor pages to the BusinessBase class without using a factory class. How do we call a method with a different name via the factory. Lets say I have a bussiness object EmployeeEquipmentEdit with the following method name GetEmployeeEquipmentByDepartmentNumber(string depNumber). How do I call GetEmployeeEquipmentByDepartmentNumber(string depNumber) from the factory class. Is their way to accomplish this. Below is what I think we could do but im not sure how to make it work. BusinessBase class
Factory Class
|
Beta Was this translation helpful? Give feedback.
-
Hello @rockfordlhotka, Here is another sample of what I am trying to do. From my factory I would rather call the method DepartmentList.GetSectionsByDivisionNumberAsync() by name and not just DepartmentList.FetchAsync(string DivisionNumber). This particular object DepartmentList has also Section Number, and Department Number so there will be a chance I will the following methods DepartmentList.FetchAsync(string SectionNumber) and DepartmentList.FetchAsync(string DepartmentNumber) which will not work since the fetch has the same method signature.
|
Beta Was this translation helpful? Give feedback.
On the client-side you are interacting with the client-side data portal, and it has specific method names you can't change.
On the server-side, you get to name your server-side data portal operation methods as you choose, using the operation attributes so the data portal can identify which methods correspond to an operation.
If you want customized names for things on the client, you should consider using a factory type. Form example: