Results 1 to 3 of 3

Thread: Parameter column in LINQ

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    2

    Parameter column in LINQ

    Hi, people!

    Can I use LINQ with parameters?

    For example, in SQL it´s possible:

    SELECT @colum1, @colum2
    from @table

    Someone know´s that is possible to do the same thing in LINQ?

    I tried to do, like this:

    Dim db As New ReceitaDataContext
    Dim command = From cla In bd.???? _
    Select cla.????, cla.????

    DataGridView.DataSource = Command.ToList

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: Parameter column in LINQ

    No, as far as I know, you can't use LINQ in that fashion. There's ways around that though. What kind of structures are bd and cla? I can write you up an example if I knew more about them.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    2

    Cool Re: Parameter column in LINQ

    Hi Jenner!
    First of all, thank´s!

    Let´s me see one example using Northwind Database

    I have created one Linq to SQL Classe and put all the tables of Northwind like Region, Products and Customers.

    I´m trying to do something like this:

    Public Function createquery()
    Dim db As New NorthWindLINQDataContext

    Dim qr = From pro In db.Products _
    Where pro.ProductID = 1 _
    Select pro.ProductID, pro.ProductName
    Return qr.ToList
    End Function


    If i use this form, it´s ok. But I´m interested in create one query with LINQ like this:

    Dim qr = From pro In db.@parameter_table _
    Where pro.@parameter_column = 1 _
    Select pro.column1, pro.column2

    It´s is possible?

    Thank´s

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width