We want to add custom made columns to a view. For example, lets say that we have a view that returns a patient's First Name, Last Name and Middle Name and we want to have extra columns based on those three like: FullNameInverse, FullName, ShortName and ShortNameInverse.
It would be much more flexible to be able to add this columns in the typedRow class instead of trying to build the column using SQL directly in the Database View.
For example the following whould be very usefull in a TypedRow class:
// __LLBLGENPRO_USER_CODE_REGION_START CustomTypedRowCode
public string PatientNameInverse
{
get
{
if (0 == this.PatientLastName.Length && 0 == this.PatientFirstName.Length && 0 == this.PatientMiddleName.Length)
return "";
return string.Format("{0}, {1} {2}", this.PatientLastName, this.PatientFirstName, this.PatientMiddleName).Trim();
}
}
and
public string PatientName
{
get
{
if (this.PatientMiddleName.Length > 0)
return string.Format("{0} {1} {2}", this.PatientFirstName, this.PatientMiddleName, this.PatientLastName).Trim();
else
return string.Format("{0} {1}", this.PatientFirstName, this.PatientLastName).Trim();
}
}
// __LLBLGENPRO_USER_CODE_REGION_END
Then in typed views we might need to add custom fill methods that use specific criteria. Lets say that we have a view that returns medical reports and we want to build a custom method that would return draft reports. We want to put that method in the typedView class because we use it in different parts of our application.
The folowing would be usefull:
// __LLBLGENPRO_USER_CODE_REGION_START CustomTypedViewCode
public bool GetReportsDrafts(int siteID, int accountID, Role userRole, int rowsToReturn, ISortExpression sortClauses)
{
IPredicateExpression selectFilter = BuildReportsDraftsFilter(accountID, userRole, siteID);
return Fill(rowsToReturn, sortClauses, true, selectFilter);
}
......
private IPredicateExpression BuildReportsDraftsFilter(int accountID, Role userRole, int siteID)
{
IPredicateExpression filter = new PredicateExpression(PredicateFactory.CompareValue(ExplorerFieldIndex.ReportStatus, ComparisonOperator.Equal, ReportStatus.Draft));
.......
return filter;
}
// __LLBLGENPRO_USER_CODE_REGION_END
Collections already support this functionallity. Why not TypedViews as well?
What we do now is, add this custom code regions in TYpedView and TypedViewRow and do the merge manually after code regeneration