Управление источником данных объекта здания из кода
Если у меня в aspx есть элемент управления entitydatasource (который выглядит так и был создан мастером настройки в конструкторе и работает)
<asp:EntityDataSource ID="edsFuelPrices" runat="server"
ConnectionString="name=enerEntities" DefaultContainerName="enerEntities"
EnableFlattening="False" EntitySetName="dieselprices" Select="it.[date], it.[NYMarineDiesel]">
</asp:EntityDataSource>
Я хочу встроить это в код и удалить все атрибуты из разметки aspx. Почему не работает следующее? Я получаю ошибки при загрузке "Синтаксис запроса недопустим. Почти экранированный идентификатор" [NYMarineDiesel] ", строка 1, столбец 21", хотя NYMarineDiesel является допустимым столбцом в таблице
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
' when page loads for the first time just show the Marine diesel prices
Try
edsFuelPrices.ConnectionString = "name=enerteckEntities"
edsFuelPrices.DefaultContainerName = "enerteckEntities"
edsFuelPrices.EnableFlattening = False
edsFuelPrices.EntitySetName = "dieselprices"
'edsFuelPrices.Include = "Date,NYMarineDiesel"
edsFuelPrices.Select = "it.[Date], it[NYMarineDiesel]"
Catch ex As Exception
MsgBox("An error occurred while loading this page: " & ex.Message.ToString())
End Try
Else
'need to add the code on postbacks, the data returned for the chart is determined by what checkboxes are checked in the checkboxlist
End If
'FormatXAxisLabels(chtFuelPrices, "MainChartArea", 9)
FormatYAxisLabels(chtFuelPrices, "MainChartArea", 9)
FormatLineCharts(chtFuelPrices, True, "MainLegend", "Fuel Types")
End Sub
1 ответ
Вы не пропустили точку между 'it' и названием свойства? - у тебя есть it[NYMarineDiesel]
и я считаю, что вы должны иметь it.[NYMarineDiesel]"