在SQL数据库解决Me.Products [英] Addressing Me.Products in an SQL Database

查看:109
本文介绍了在SQL数据库解决Me.Products的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理 Me.Products ?我使用Northwind.mdf数据库表中的产品。该表是药到DBML文件。

Me.Products 需要与陈述或文件,使其可用来定义。也许朦胧的说法是不正确的?

 部分公共类NorthwindDataContext
    昏暗的产品为对象
    公共职能GetProductsByCategory(BYVAL ID1作为整数)为IEnumerable(以产品)
        返回从p在Me.Products _
               凡p.ProductID = ID1 _
               选择p
    结束功能
末级


解决方案

我在VB中非常薄弱,但仍然尝试
是暗淡用于创建变量。首先创建northwinddatacontext为如的对象。

 昏暗的分贝作为新northwinddatacontext()

那么你可以得到表作为

  VAR的查询=从p在db.Products
            其中,p.ProductID = ID
            的选择p

How do I handle Me.Products? I am using Northwind.mdf database in table "Products". The table was drug onto a dbml file.

Me.Products needs to be defined with a statement or a file to make it usable. Maybe the dim statement is incorrect?

Partial Public Class NorthwindDataContext
    Dim Products As Object
    Public Function GetProductsByCategory(ByVal id1 As Integer) As IEnumerable(Of Product)
        Return From p In Me.Products _
               Where p.ProductID = id1 _
               Select p
    End Function
End Class

解决方案

I am very weak in VB but still try it yes dim is used to create variables. First create an object of northwinddatacontext for eg.

dim db as new northwinddatacontext() 

then you can get the table as

var query = from p in db.Products 
            where p.ProductID = id 
            select p

这篇关于在SQL数据库解决Me.Products的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆