0
エンティティフレームワークで作業しています.2つの値をフェッチし、後でいくつかの操作を行ったデータテーブルを返すために、ado.netで関数を記述していました。 コードはエンティティフレームワークの匿名型の戻り値と操作の問題
Protected Sub ddlFieldMappingProfile_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlFieldMappingProfile.SelectedIndexChanged
If ddlFieldMappingProfile.SelectedValue >= 0 Then
btnImportData.Enabled = True
End If
If ddlFieldMappingProfile.SelectedValue <= 0 Then Return
Dim lstHeaders As List(Of String)
Dim dtMapping As New DataTable()
Dim intCount As Integer = 0
Try
Using com As New Common
With com
dtMapping = .getProfileFields(Convert.ToInt32(ddlFieldMappingProfile.SelectedValue))
IEMapping = .getProfileFields(Convert.ToInt32(ddlFieldMappingProfile.SelectedValue))
lstHeaders = .FileHeaders(FileUpl.FiletoRead, FileUpl.Delimiter)
End With
End Using
dtMapping.Columns.Add("MatchIndex")
For Each row As DataRow In dtMapping.Rows
For intCount = 0 To lstHeaders.Count() - 1
If lstHeaders(intCount) = row.Item("Dump_FieldName") Then
row.Item("MatchIndex") = intCount
Exit For
Else
row.Item("MatchIndex") = -1
End If
Next
Next
gdvFieldData.DataSource = dtMapping
gdvFieldData.DataBind()
gdvFieldData.Visible = True
Catch ex As Exception
Throw ex
Finally
dtMapping.Dispose()
lstHeaders = Nothing
End Try
End Sub
But now that I am using entity frame work I have written the LINQ query like
Dim Context As New ICOM_Model.IcomsEntities()
Dim query = From F In Context.Incentive_Prepaid_FieldMapping Where F.Profile_ID = Profile_ID
Select New With {.Activations_FieldName = F.Activations_FieldName, .Dump_FieldName = F.Dump_FieldName}
匿名タイプです。 2プロパティ「Activations_FieldNameとDump_FieldName」と匿名になりますし、その値にアクセスできる戻り値の型であることを何が起こっているか私を助けて、どのように私はあなたのコードの戻り値の型ではddlFieldMappingProfile_SelectedIndexChanged