Since I am new to working a C# 2010 console application, I have the following questions to ask about how to accomplish the following tasks:
1. I would like to use linq to sql on a sql server 2008 r2 database to pull all the data from one column in one particular table. The value for the one array would be varchar(50) There will be more than one row selected at the time. (What I have seen of linq so far is to pull only one value by using singleordefault.)
2. I then would like to take the values obtained from step number one and load those values into array,collection, or some type of similar object.
Can tell me how to accomplisth this goal and/or point me to a reference that I can use?
Loading
VulpesPosted Sep 6, 2012, 1:01 PM
dcPosted Sep 6, 2012, 12:39 PM
string[] names
= context.Customers.Select(c => c.Name).ToArray();
How would I change this statement to mean the following from the sql?
select customer_id from Customers where customer_received_date is not null
VulpesPosted Sep 6, 2012, 11:35 AM
Just access them as you normally would - so names[0] is the first name in the array, names[1] is the second and so forth.
To make sure it's giving the right answers you could iterate the array as follows:
foreach(string name in names) Console.WriteLine(name);
dcPosted Sep 6, 2012, 11:20 AM
Now how would I access each item (names) in the array?
VulpesPosted Sep 6, 2012, 10:20 AM