2015-10-15 69 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