Check whether column name exist in IQueriable<DataRow>
- i check whether column name exist in IQueriable<DataRow> by copy the data to a DataTable and then check whehter the column exist:
myQueriableData.CopyToDataTable().Columns.Contains("MyColumn")
is CopyToDataTable() the only way to check whether the colum name exist ? can i check for the column name in Linq on myQueriableData?
i think that transforming the data into a datatable each time i check, will slow down the application....
Answers
Hi rodniko,
We can directly get the DataTable of a certain DataRow by calling DataRow.Table property.
==========================================================
myQueriableData.First().Table.Columns.Contains(“MyColumn”);
==========================================================If you have any questions, please feel free to let me know.
Have a nice day!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byrodniko Sunday, November 08, 2009 11:36 AM
All Replies
- Would following work?
bool isColumnThere = (from DataRow dRow
in YourQueriableList
where dRow.Table.Columns.Contains("YourColumnName")
select 0).Count() > 0 ? true : false;
Thanks,
Viral.
Hi rodniko,
We can directly get the DataTable of a certain DataRow by calling DataRow.Table property.
==========================================================
myQueriableData.First().Table.Columns.Contains(“MyColumn”);
==========================================================If you have any questions, please feel free to let me know.
Have a nice day!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byrodniko Sunday, November 08, 2009 11:36 AM
Hi rodniko,
Does the workaround helpful to you?
If you need any further assistance, please feel free to let me know.
Have a nice day!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Works great , thanks!


