Hi,
Newbie question here. Is there a best practice to add my own factory method?
I have an employee table in the DB, which has a primary key. I used CodeSmith to generate the business object. So now I have a Employee.GetEmployee(guid pk) method.
What I'd like to do is add a method something like GetEmployeeByUserNamePassword(string userName, string password). As I'm new to this, I'm a little lost on the proper way to implement.
Any thoughts appreciated. Thanks,
Mike
Hello Andy,
Thanks for the reply. I guess what I'm confused about is *how* do I go about implementing a new method?
Right now - and I used CodeSmith to generate the code - I have a method that looks like this:
public static Employee GetEmployee(Guid pk){
if (!CanGetObject()) throw new System.Security.SecurityException("User not authorized to view a Employee"); return DataPortal.Fetch<Employee>(new Criteria(pk));}
This calls DataPortal.Fetch, which then in turn (I'm assuming right now - not an expert at CSLA yet) calls
private
void DataPortal_Fetch(Criteria criteria)I don't think I should be messing with the DataPortal class. Should I create another DataPortal_Fetch method? If I do, I'm going to need something besides my generated Criteria class, because that has a single member and one constructor:
private class Criteria{
public Guid PK; public Criteria(Guid pk){
this.PK = pk;}
}
Hope that makes sense. Since I'd like to pass in two strings and not a Guid to get the Employee object, I guess I could add some members to Criteria, then check to see if those members are not null in the DataPortal_Fetch method. I'm not sure if this is the proper way to go about it.Thaks,
Mike
Thank you Andy, makes sense to me.
Regards,
Mike
Copyright (c) Marimer LLC