I am trying to query black spaces in the database using LLBL Gen Pro. Some in the database, the value is a blank (not null). Can someone tell me how do I do it?
I have tried a few way, but none of them works correctly.
filter.AddWithAnd(RecipeFields.FeaturedItem % ""); //way 1
filter.AddWithAnd(RecipeFields.FeaturedItem == String.empty); // way 2
filter.AddWithAnd(RecipeFields.FeaturedItem == System.DBNull.value); // way 3
I haven't tested it, but it should work:
var predicateBucket = new RelationPredicateBucket();
var trimedLengthPredicate = new EntityField("FeaturedItemEmptyLength",
new DbFunctionCall("LENGTH", new Object() { new DbFunctionCall("RTRIM", new Object() { new DbFunctionCall("LTRIM", new Object() { RecipeFields.FeaturedItem })})})) == 0;
var emptryTextPredicate = RecipeFields.FeaturedItem % "% %";
predicateBucket.PredicateExpression.Add(trimedLengthPredicate & emptryTextPredicate);
Which is a predicate for this query:
SELECT * FROM RecipeFields r WHERE LENGTH(LTRIM(RTRIM(r.FeaturedItem))) = 0 AND r.FeaturedItem LIKE '% %';
Warning: This predicate checks only for space, not TAB or Enter characters.
For more info: https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=23385