LLBLGen Pro:如何评估给定字符串的 EntityField

发布于 2024-08-02 06:23:50 字数 893 浏览 3 评论 0原文

我有一个 LLBLGen Pro 项目,它生成了 VB.Net 2.0 自助服务代码。

我有一个函数可以根据使用生成的代码的搜索返回自定义结构列表。

我想为此函数提供一个字段名称和值的字典,并为每个字段名称和值的字典添加一个新的谓词表达式到搜索中。

如何检查字典中表示字段名称的字符串并找出要为其添加谓词表达式的 EntityField?

代码示例

Dim dbFiles As New AllFilesCollection
Dim dbFilter As New PredicateExpression

If Not String.IsNullOrEmpty(ClientName) Then
  dbFilter.Add(New PredicateExpression(AllFilesFields.ClientMenuName = ClientName))
End If

If Not String.IsNullOrEmpty(SearchText) Then
  dbFilter.Add(New FieldLikePredicate(AllFilesFields.ClientReference, "%" & SearchText & "%"))
  dbFilter.AddWithOr(New FieldLikePredicate(AllFilesFields.Cmsnumber, "%" & SearchText & "%"))
End If

For Each Filter As KeyValuePair(Of String, String) In Filters

  'Custom code here to determine the field to add a filter for.

Next

dbFiles.GetMulti(dbFilter)

I have an LLBLGen Pro project which has generated VB.Net 2.0 Self Servicing code.

I have a function to return a list of custom structures based on a search using the generated code.

I would like to supply a Dictionary of FieldNames and Values to this function and for each one add a new Predicate Expression to the search.

How can I check the String within the dictionary that represents the Field name and work out which EntityField to add the Predciate Expression for?

Code Sample

Dim dbFiles As New AllFilesCollection
Dim dbFilter As New PredicateExpression

If Not String.IsNullOrEmpty(ClientName) Then
  dbFilter.Add(New PredicateExpression(AllFilesFields.ClientMenuName = ClientName))
End If

If Not String.IsNullOrEmpty(SearchText) Then
  dbFilter.Add(New FieldLikePredicate(AllFilesFields.ClientReference, "%" & SearchText & "%"))
  dbFilter.AddWithOr(New FieldLikePredicate(AllFilesFields.Cmsnumber, "%" & SearchText & "%"))
End If

For Each Filter As KeyValuePair(Of String, String) In Filters

  'Custom code here to determine the field to add a filter for.

Next

dbFiles.GetMulti(dbFilter)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扎心 2024-08-09 06:23:50

我认为这个问题已被忽略,因为它看起来像 LLBLGEN 问题,但可能不是。

如果您知道所有列:

  • City
  • State
  • Zip

然后您只需将字符串转换为这样的值...

For Each Filter As KeyValuePair(Of String, String) In Filters
    Select Case filter.Key
        Case "City"
            dbFilter.Add(New PredicateExpression(AllFilesFields.City = filter.Value))
        Case "State"
            dbFilter.Add(New PredicateExpression(AllFilesFields.State = filter.Value))
        Case "Zip"
            dbFilter.Add(New PredicateExpression(AllFilesFields.Zip = filter.Value))
    End Select
Next

I think that this question has been ignored because it looks like an LLBLGEN question, but it probably isn't.

If you know all of your Columns:

  • City
  • State
  • Zip

Then you just need to convert your string to those values like this...

For Each Filter As KeyValuePair(Of String, String) In Filters
    Select Case filter.Key
        Case "City"
            dbFilter.Add(New PredicateExpression(AllFilesFields.City = filter.Value))
        Case "State"
            dbFilter.Add(New PredicateExpression(AllFilesFields.State = filter.Value))
        Case "Zip"
            dbFilter.Add(New PredicateExpression(AllFilesFields.Zip = filter.Value))
    End Select
Next
亣腦蒛氧 2024-08-09 06:23:50

你也可以这样做:

Dim fields As IEntityFields = new AllFieldsEntityFactory().CreateFields();
For Each Filter As KeyValuePair(Of String, String) In Filters
    dbFilter.Add((EntityField) fields[Filter.Key] == Filter.Value);
Next

You also could do something like this:

Dim fields As IEntityFields = new AllFieldsEntityFactory().CreateFields();
For Each Filter As KeyValuePair(Of String, String) In Filters
    dbFilter.Add((EntityField) fields[Filter.Key] == Filter.Value);
Next
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文