I have database of external program that I want to connect and operate on through LINQ to SQL. My problem is , I want to support wider range of versions of database, so I have to check for columns if they exists.
I tried something like that:
IEnumerable<string> k = db.ExecuteQuery<string>("select column_name from INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME='{0}' and TABLE_NAME='POSIEDZENIA'", column);
And it gives me nothing. k.Count() gives error:
The result of a query cannot be enumerated more than once
When I cast it to List by ToList() it gives 0 count.
I'm sure that this column exists in database that datacontext is connected to.
Have you any suggestions?
Just remove quotation around parameter ( {0}
).
IEnumerable<string> k = db.ExecuteQuery<string>("select column_name from
INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME={0} and TABLE_NAME='POSIEDZENIA'", column);
for more information visit this msdn article .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.