English 中文(简体)
如何管理结构相同的多个表格(核心)
原标题:How to manage multiple tables with the same structure (redux)

我发现这个问题与我想解决的问题类似:

如何管理结构相同的多个表格

然而,由于VB的弹性性质,解决办法确实没有奏效。 具体来说,由于VB,它不工作。 该网络要求明确宣布在接口中采用每一种方法/财产。

至于我真心要解决的问题,这就是:

  • I have many lookup/domain tables in the database that all have the same structure
  • The items in these tables are typically used for drop downs in the interface
  • I would like to avoid a bunch of boilerplate repository methods to retrieve the contents of these tables (one method per table really sucks when you have 40 tables)
  • I am not using the One True Lookup Table anti-pattern and this is not an option

是否有任何其他办法在VB开展工作?

最佳回答

我们最后使用的是:

Public Function GetDomainTableList(tableName As String) As IEnumerable(Of Object)

    Dim table = CType(GetType(FECEntities).GetProperty(tableName).GetValue(DB, Nothing), IEnumerable(Of Object))

    Dim dt = From r In table
             Select r

    Return dt.ToList()

End Function

我原先曾认为,由于我试图将每一物体重新编为<代码>,这对我们来说是徒劳的。 项目类别,我已撰写。 但当时我认识到,<代码>SelectList 施工者没有真正地关注其使用的物体类型。 你只是通过载有财产名称的“努力”,并利用反思来收回价值。

因此,所有东西都以这种方式行事,我避免撰写每个领域/分局的一种方法。

问题回答

Generic Repository should work in this case. There are many available online or you can write a simpler one for just the lookup tables.





相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签