Solved

Linq query with "where" statement

Posted on 2014-12-11
6
89 Views
Last Modified: 2016-02-15
Hello,

i'm using the following linq query:

var query = from tbl1 in dt.AsEnumerable()
     select new { ID = tbl1["1"], Name = tbl1["3"]}   ;

Open in new window


This works fine. How could i use the SQL "where" Statement like this?

var query = from tbl1 in dt_Sachkonto.AsEnumerable()
           select new { ID = tbl1["1"], Name = tbl1["3"]  where tbl1["1"].ToString() == "400"}   ;

Open in new window



This should select all records with ID = 400. But it doesn't work.

Thank you very much
Kind Regards
Bounty
0
Comment
Question by:bounty457
  • 3
  • 3
6 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40494575
Try it like this.

var query = from tbl1 in dt_Sachkonto.AsEnumerable()
            where tbl1["1"].ToString() == "400" 
            select new 
            { 
              ID = tbl1["1"], 
              Name = tbl1["3"]
            };

Open in new window

0
 
LVL 1

Author Comment

by:bounty457
ID: 40494618
Nice, thank you very much, it works.

Kind Regrads
Bounty
0
 
LVL 1

Author Comment

by:bounty457
ID: 40494640
I've requested that this question be closed as follows:

Accepted answer: 0 points for bounty457's comment #a40494618

for the following reason:

Great
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40494641
Hi Bounty;

I suspect that the solution I posted work for you but you have closed this question by assigning zero points to yourself but did not assign any points to the solution that you stated works. Can you please close the question by assigning the correct solution the points.

Thank you.
0
 
LVL 1

Author Closing Comment

by:bounty457
ID: 40494681
Really good work. :-)
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40494693
Thank you. 👍
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question