linq question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CSharper

    linq question

    I would like know, will it be possible to run a linq statement
    generated on the fly by a program?

    Lets say, I have string like the following
    string t = "from c in doc.Decentents( 'Value') select c";

    Is there anyway I would able to run this?

    Thanks.
  • Jon Skeet [C# MVP]

    #2
    Re: linq question

    CSharper <csharper@gmx.c omwrote:
    I would like know, will it be possible to run a linq statement
    generated on the fly by a program?
    >
    Lets say, I have string like the following
    string t = "from c in doc.Decentents( 'Value') select c";
    >
    Is there anyway I would able to run this?
    You can use the CSharpCodeProvi der to compile code, if that helps.

    --
    Jon Skeet - <skeet@pobox.co m>
    Web site: http://www.pobox.com/~skeet
    Blog: http://www.msmvps.com/jon_skeet
    C# in Depth: http://csharpindepth.com

    Comment

    • CSharper

      #3
      Re: linq question

      On Jun 24, 4:39 pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
      CSharper <cshar...@gmx.c omwrote:
      I would like know, will it be possible to run a linq statement
      generated on the fly by a program?
      >
      Lets say, I have string like the following
      string t = "from c in doc.Decentents( 'Value') select c";
      >
      Is there anyway I would able to run this?
      >
      You can use the CSharpCodeProvi der to compile code, if that helps.
      >
      --
      Jon Skeet - <sk...@pobox.co m>
      Web site:http://www.pobox.com/~skeet 
      Blog:http://www.msmvps.com/jon_skeet
      C# in Depth:http://csharpindepth.com
      Thanks Jon, What I am trying to do is similar to SQL, I want to build
      the Linq on the fly on which columns to display and then like sql
      executescalar or something, is it possible to run the build linq? I
      want to execute the linq statement I build.

      Comment

      • Michael F. Sargent

        #4
        Re: linq question

        If you look in the following path file:\\C:\Progr am Files\Microsoft Visual Studio 9.0\Samples\103 3\ you will see a zip file called
        CSharpSamples.z ip. Inside is a folder called "LinqSample s" and another called "LanguageSample s". The LinqSamples includes a folder
        called DynamicQuery which shows how to do this.

        For example:

        var query =
        db.Customers.
        Where("City = @0 and Orders.Count >= @1", "London", 10).
        OrderBy("Compan yName").
        Select("new(Com panyName as Name, Phone)");

        I have used this will LINQ to SQL and it works well. I don't understand why Microsoft didn't make this a standard part of .NET 3.5
        (since they almost did it with LinqDataSource) .

        I haven't tried it with XML. Let us know how it works.

        Mike

        "CSharper" <csharper@gmx.c omwrote in message news:331086e1-a7cf-4809-80de-c8c6b48bf903@i7 6g2000hsf.googl egroups.com...
        On Jun 24, 4:39 pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
        CSharper <cshar...@gmx.c omwrote:
        I would like know, will it be possible to run a linq statement
        generated on the fly by a program?
        >
        Lets say, I have string like the following
        string t = "from c in doc.Decentents( 'Value') select c";
        >
        Is there anyway I would able to run this?
        >
        You can use the CSharpCodeProvi der to compile code, if that helps.
        >
        --
        Jon Skeet - <sk...@pobox.co m>
        Web site:http://www.pobox.com/~skeet
        Blog:http://www.msmvps.com/jon_skeet
        C# in Depth:http://csharpindepth.com
        Thanks Jon, What I am trying to do is similar to SQL, I want to build
        the Linq on the fly on which columns to display and then like sql
        executescalar or something, is it possible to run the build linq? I
        want to execute the linq statement I build.


        Comment

        • Frans Bouma [C# MVP]

          #5
          Re: linq question

          Michael F. Sargent wrote:
          If you look in the following path file:\\C:\Progr am Files\Microsoft Visual Studio 9.0\Samples\103 3\ you will see a zip file called
          CSharpSamples.z ip. Inside is a folder called "LinqSample s" and another called "LanguageSample s". The LinqSamples includes a folder
          called DynamicQuery which shows how to do this.
          >
          For example:
          >
          var query =
          db.Customers.
          Where("City = @0 and Orders.Count >= @1", "London", 10).
          OrderBy("Compan yName").
          Select("new(Com panyName as Name, Phone)");
          >
          I have used this will LINQ to SQL and it works well. I don't understand why Microsoft didn't make this a standard part of .NET 3.5
          (since they almost did it with LinqDataSource) .
          why on earth would anyone use string based queries? You then can also
          simply use SQL embedded in strings...

          FB
          >
          I haven't tried it with XML. Let us know how it works.
          >
          Mike
          >
          "CSharper" <csharper@gmx.c omwrote in message news:331086e1-a7cf-4809-80de-c8c6b48bf903@i7 6g2000hsf.googl egroups.com...
          On Jun 24, 4:39 pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
          >CSharper <cshar...@gmx.c omwrote:
          >>I would like know, will it be possible to run a linq statement
          >>generated on the fly by a program?
          >>Lets say, I have string like the following
          >>string t = "from c in doc.Decentents( 'Value') select c";
          >>Is there anyway I would able to run this?
          >You can use the CSharpCodeProvi der to compile code, if that helps.
          >>
          >--
          >Jon Skeet - <sk...@pobox.co m>
          >Web site:http://www.pobox.com/~skeet
          >Blog:http://www.msmvps.com/jon_skeet
          >C# in Depth:http://csharpindepth.com
          >
          Thanks Jon, What I am trying to do is similar to SQL, I want to build
          the Linq on the fly on which columns to display and then like sql
          executescalar or something, is it possible to run the build linq? I
          want to execute the linq statement I build.
          >
          >

          --
          ------------------------------------------------------------------------
          Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
          LLBLGen Pro website: http://www.llblgen.com
          My .NET blog: http://weblogs.asp.net/fbouma
          Microsoft MVP (C#)
          ------------------------------------------------------------------------

          Comment

          Working...