2015-10-15 171 views
0

我想用LLBL Gen Pro查询数据库中的黑色空格。 某些在数据库中的值为空(不为空)。 有人能告诉我我该怎么做吗?LLBLGenPro:查询空白

我尝试了一些方法,但没有一个能够正常工作。

filter.AddWithAnd(RecipeFields.FeaturedItem % ""); //way 1 

filter.AddWithAnd(RecipeFields.FeaturedItem == String.empty); // way 2 

filter.AddWithAnd(RecipeFields.FeaturedItem == System.DBNull.value); // way 3 

回答

1

我没有测试它,但它应该工作:

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); 

这是该查询谓词:

SELECT * FROM RecipeFields r WHERE LENGTH(LTRIM(RTRIM(r.FeaturedItem))) = 0 AND r.FeaturedItem LIKE '% %'; 

警告:此断言只检查空格,而不是TAB或输入字符。

欲了解更多信息:https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=23385