对象数据源数据对象类型名称帮助。 将对象作为参数传递

发布于 2024-07-27 04:55:12 字数 1362 浏览 0 评论 0原文

我有一个分部类(主类是 LinqToSql 生成的类)

   <DataObject(True)> _
Partial Public Class MBI_Contract

    <DataObjectMethod(DataObjectMethodType.Select, True)> _
   Public Shared Function GetCancelableContracts(ByVal dealer As Dealer) As List(Of MBI_Contract)
        Return Utilities.GetCancelableContractsForDealer(dealer)
    End Function
End Class

这是它调用的方法

Public Function GetCancelableContractsForDealer(ByVal dealer As Dealer) As List(Of MBI_Contract)
        Dim db As TestDataContext = TestDataContext.Create()
        Return (From mbi As MBI_Contract In db.MBI_Contracts _
                                 Where mbi.MBI_DealerNumber = dealer.DealerNumber _
                                 AndAlso mbi.MBI_PaidFor = True _
                                 AndAlso mbi.MBI_Deleted = False).ToList()
    End Function

我想使用 ObjectDataSource 来驱动 DropDownList。

  <asp:ObjectDataSource ID="contractOds" runat="server" 
         TypeName="MBI_Contract"
         SelectMethod="GetCancelableContracts" 
         DataObjectTypeName="Dealer">
    </asp:ObjectDataSource>

我的 aspx 页面有一个在 BasePage 中设置的 Dealer 属性。 我的问题是如何将此属性(对象)传递给 ObjectDataSource,以便可以在我的 select 方法中对其进行评估。 有谁知道我该怎么做? 或者我完全以错误的方式做这件事?

感谢您的任何建议, 干杯, 〜ck在圣地亚哥

I have a partial class (the main class is a LinqToSql generated class)

   <DataObject(True)> _
Partial Public Class MBI_Contract

    <DataObjectMethod(DataObjectMethodType.Select, True)> _
   Public Shared Function GetCancelableContracts(ByVal dealer As Dealer) As List(Of MBI_Contract)
        Return Utilities.GetCancelableContractsForDealer(dealer)
    End Function
End Class

Here is the method it's calling

Public Function GetCancelableContractsForDealer(ByVal dealer As Dealer) As List(Of MBI_Contract)
        Dim db As TestDataContext = TestDataContext.Create()
        Return (From mbi As MBI_Contract In db.MBI_Contracts _
                                 Where mbi.MBI_DealerNumber = dealer.DealerNumber _
                                 AndAlso mbi.MBI_PaidFor = True _
                                 AndAlso mbi.MBI_Deleted = False).ToList()
    End Function

I want to use the ObjectDataSource to drive a DropDownList.

  <asp:ObjectDataSource ID="contractOds" runat="server" 
         TypeName="MBI_Contract"
         SelectMethod="GetCancelableContracts" 
         DataObjectTypeName="Dealer">
    </asp:ObjectDataSource>

My aspx page has a Dealer property that is set in a BasePage. My question is how can I pass this property(object) to the ObjectDataSource, so it can be evaluated in my select method. Does anyone know how I can do this? Or am I totally doing this the wrong way?

Thanks for any Advice,
Cheers,
~ck in San Diego

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

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

发布评论

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

评论(1

烛影斜 2024-08-03 04:55:13
Protected Sub contractOds_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles contractOds.Selecting
    e.InputParameters.Insert(0, "dealer", Dealer)

End Sub

这似乎有效。

Protected Sub contractOds_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles contractOds.Selecting
    e.InputParameters.Insert(0, "dealer", Dealer)

End Sub

This seems to work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文