Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CommandBehavior.SchemaOnly
Message
De
30/07/2013 12:00:07
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01579375
Message ID:
01579438
Vues:
39
This message has been marked as a message which has helped to the initial question of the thread.
>>>>>>>Hi Viv,
>>>>>>>
>>>>>>>If I change definition of the TableSchema class to be
>>>>>>>
>>>>>>>public class TableSchema 
>>>>>>>{
>>>>>>>
>>>>>>>internal String TableName;
>>>>>>>
>>>>>>>public List<ColumnSchema> Columns = new List<ColumnSchema>();
>>>>>>>
>>>>>>>}
>>>>>>>
>>>>>>>then how would I retrieve column schema for particular column name ?
>>>>>>
>>>>>>
var columnSchema = Columns.Where(x => x.ColumnName == "Name").FirstOrDefault();
>>>>>
>>>>>Good idea! So, you think it's better than using dictionary, right?
>>>>>
>>>>>If so, I'll try to change to your code and use a List.
>>>>
>>>>Don't see much point in a Dictionary here. And IEnumerable might be better the List....
>>>
>>>In our conversion we mostly use Dictionary. I think it's done mostly because of our ignorance and not enough knowledge to use Linq that way you showed.
>>>
>>>I am going to try using list for this particular class and see if there will be a speed benefit.
>>>
>>>One quick question - how should I access individual properties of the columnSchema using the code you showed? Say, I need to get column's DbType?
>>
>>If it's just the one property:
var dbType = Columns.FirstOrDefault(x => x.ColumnName == "Name").DbType;
>
>BTW, I am getting an error that generic list does not contain Where extension method. Which using I am missing?

A reference to System.Linq?

BTW, the last line I sent could throw a NullReferenceException if you use an invalid ColumnName......
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform