Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Iterate over columns in LINQ to SQL result
Message
 
À
18/11/2008 08:38:07
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01362512
Message ID:
01362521
Vues:
13
Craig,

I wasn't clear enough in my fist question. My first foreach loop works Ok, as does yours. What I really want is an inner foreach loop to step through the columns, something similar to:
var _CSVTests = from cs in db.CSVTests
                               select cs;

foreach (CSVTest tst in _CSVTests)
{
       foreach (Column c in tst)
           {
                 Do something with the value of each column if it isn't null.
           }
}
I know the "foreach (Column c in tst) " part is not proper. What is?

How do I get a collection of columns for each "record" in my _CSVTests ?

Thanks.


>You can't define tst as any particular datatype because you don't know what datatype it will be. You have to make it var.
>
>
>var _CSVTexts = from cs in db.CSVTests
>                          select cs;
>
>foreach (var tst in _CSVTests
>{
>    Console.WriteLine(tst.Column1);
>}
>
>
>>To All:
>>
>>I have the following code:
>>
>>
>>var _CSVTests = from cs in db.CSVTests
>>                         select cs;
>>
>>foreach (CSVTest tst in _CSVTests)
>>	{
>>		
>>		 In here I want to iterate over each column in each record and 
>>		 if it is not equal to NULL I want to do something with the value,
>>		 such as insert that value into another table.
>>		
>>	}
>>
>>
>>How do I access the properties and values of each column in the results of my _CSVTests? Do I use IQueryable instead of var? How will that help me? I've been searching for this answer for two days now. PLEASE HELP.
>>
>>Thank you.
Elgin Rogers
Epic Solutions
www.epicsolutions.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform