Hi.
My llblgen version is 2.0.0.0 Final, 6th December.
I have a method to fetch entities by filter. I am posting the whole thing at the end of my post, though you probably dont need the whole thing to answer my question.
The filter method accepts a free text string entered directly by the user. The search string "February 2008" should be narrower than just "February". The way sql FreeText works, this is not the case. The result set of the former search string will contain any entity where either "February" or "2008" is used. What is the best way to code a search, using llblgen, that becomes more narrow with more freetext words (like an ordinary google search).
Thx,
Tore
public EntityCollection<ReportInstanceEntity> FetchReportInstancesByFilter(long reportTypeId, string reportNumber, bool? isValid, string submittedByUser, DateTime? submittedFromDate, DateTime? submittedToDate, string lastSavedByUser, DateTime? lastSavedFromDate, DateTime? lastSavedToDate, string startedByUser, DateTime? startedFromDate, DateTime? startedToDate, string freeText) {
using (DataAccessAdapter adapter = new DataAccessAdapter()) {
EntityCollection<ReportInstanceEntity> reportInstances = new EntityCollection<ReportInstanceEntity>();
IRelationPredicateBucket filter = new RelationPredicateBucket();
filter.Relations.Add(ReportInstanceEntity.Relations.WizardStepDataRowInstanceEntityUsingReportInstanceId);
filter.Relations.Add(WizardStepDataRowInstanceEntity.Relations.WizardStepDataFieldValueEntityUsingWizardStepDataRowInstanceId);
if (reportTypeId > 0) {
filter.PredicateExpression.Add(new FieldCompareValuePredicate(ReportInstanceFields.ReportTypeId, null, ComparisonOperator.Equal, reportTypeId));
}
if (reportNumber.Length > 0) {
filter.PredicateExpression.Add(new FieldLikePredicate(ReportInstanceFields.ReportNumber, null, "%" + reportNumber + "%"));
}
if (isValid != null) {
filter.PredicateExpression.Add(new FieldCompareValuePredicate(ReportInstanceFields.IsValid, null, ComparisonOperator.Equal, isValid));
}
if (!string.IsNullOrEmpty(submittedByUser)) {
filter.PredicateExpression.Add(new FieldCompareValuePredicate(ReportInstanceFields.SubmittedByUser, null, ComparisonOperator.Equal, submittedByUser));
}
if (submittedFromDate != null && submittedToDate != null) {
filter.PredicateExpression.Add(new FieldBetweenPredicate(ReportInstanceFields.SubmittedDate, null, submittedFromDate, submittedToDate.Value.AddDays(1)));
}
if (!string.IsNullOrEmpty(lastSavedByUser)) {
filter.PredicateExpression.Add(new FieldCompareValuePredicate(ReportInstanceFields.LastSavedByUser, null, ComparisonOperator.Equal, lastSavedByUser));
}
if (lastSavedFromDate != null && lastSavedToDate != null) {
filter.PredicateExpression.Add(new FieldBetweenPredicate(ReportInstanceFields.LastSavedDate, null, lastSavedFromDate, lastSavedToDate.Value.AddDays(1)));
}
if (!string.IsNullOrEmpty(startedByUser)) {
filter.PredicateExpression.Add(new FieldCompareValuePredicate(ReportInstanceFields.StartedByUser, null, ComparisonOperator.Equal, startedByUser));
}
if (startedFromDate != null && startedToDate != null) {
filter.PredicateExpression.Add(new FieldBetweenPredicate(ReportInstanceFields.StartedDate, null, startedFromDate, startedToDate.Value.AddDays(1)));
}
if (!string.IsNullOrEmpty(freeText)) {
//string[] freeTextSearchArray = freeText.Split(' ');
//foreach (string freeTextString in freeTextSearchArray) {
filter.PredicateExpression.Add(new FieldFullTextSearchPredicate(WizardStepDataFieldValueFields.Value, null, FullTextSearchOperator.Freetext, freeText));
//}
}
adapter.FetchEntityCollection(reportInstances, filter);
return reportInstances;
}
}