如何格式化BQL查询以使用“赞” sql功能。我想获取特定字段的前两个字符与字符串变量匹配的所有行。
Sql示例:
#
答案 0 :(得分:1)
像这样的东西:
public static class Constants
{
public class likeCA : Constant<string>
{
public likeCA() : base("CA%") { }
}
}
public PXSelect<MyTable,Where<MyTable.uom,Like<Constants.likeCA>>> MySelect;
答案 1 :(得分:0)
[PXCacheName("Filter")]
[Serializable]
public class ItemFilter : IBqlTable
{
#region FullDescription
[PXString(IsUnicode = true, InputMask = "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC")]
[PXUIField(DisplayName = "Full Description")]
public virtual string Description { get; set; }
public abstract class fdescription : IBqlField { }
#endregion
#region SearchDescrWildcard
[PXString(IsUnicode = true)]
public virtual string SearchDescrWildcard
{
get
{
return SearchWildcardUtils.CreateWildcard(this.Description);
}
set
{
}
}
public abstract class searchDescrWildcard : IBqlField { }
#endregion
public class SearchWildcardUtils
{
public static bool IsSearchWildcardEmpty(string aSub)
{
return aSub == null || aSub == "" || new Regex("^[_\\?]*$").IsMatch(aSub);
}
public static string CreateWildcard(string text)
{
ISqlDialect sqlDialect = PXDatabase.Provider.SqlDialect;
if (SearchWildcardUtils.IsSearchWildcardEmpty(text))
{
return sqlDialect.WildcardAnything;
}
if (text[text.Length - 1] != '?' && text[text.Length - 1] != ' ')
{
text = $"?{text}?";
}
return Regex.Replace(Regex.Replace(text, "[ \\?]+$", sqlDialect.WildcardAnything), "[ \\?]", sqlDialect.WildcardAnything);
}
}
}
public PXSelect<MyTable, Where<MyTable.description, Like<Current<ItemFilter.searchDescrWildcard>>>> SelectMyTable; // Sql Table select
cmd.WhereAnd<Where<MyTable.description, Like<Current<ItemFilter.searchDescrWildcard>>>>();// BQL query select