Answered by:
How to get data and columns from linq dynamically

Question
-
Hi,
I have a problem with linq in my scenario, where table name comes dynamically and i need to fetch all columns and records from that table. for example..
public void GetData(string tableName,int id) { DataClasses1DataContext _db = new DataClasses1DataContext(); var qry = from o in _db.Organizations where o.OrganizationId==id select o; //but here, I cannot pass Organizations table directly as It is dynamic }
So how can I give table name dynamically in context, and how to get columns also for that table.
Please give me some idea.
Thanks
VD
<style type="text/css">img.imageResizerActiveClass{cursor:nw-resize !important;outline:1px dashed black !important;} img.imageResizerChangedClass{z-index:300 !important;max-width:none !important;max-height:none !important;} img.imageResizerBoxClass{margin:auto; z-index:99999 !important; ; top:0; left:0; right:0; bottom:0; border:1px solid white; outline:1px solid black;} </style>Monday, September 2, 2013 7:12 AM
Answers
-
- Proposed as answer by Allen Li - MSFT Tuesday, September 3, 2013 6:20 AM
- Marked as answer by Allen Li - MSFT Thursday, September 12, 2013 2:23 PM
Monday, September 2, 2013 11:16 AM
All replies
-
-
No I cannot use switch case statement, becuase table name comes dynamically and it is not fixed, tables would be increased, and in that case, I have to change again in my switch case that is not possible for me.
So basically I am looking for some solution which can access data and columns both from given table name through linq.
<style type="text/css">img.imageResizerActiveClass{cursor:nw-resize !important;outline:1px dashed black !important;} img.imageResizerChangedClass{z-index:300 !important;max-width:none !important;max-height:none !important;} img.imageResizerBoxClass{margin:auto; z-index:99999 !important; ; top:0; left:0; right:0; bottom:0; border:1px solid white; outline:1px solid black;} </style>
<style type="text/css">img.imageResizerActiveClass{cursor:nw-resize !important;outline:1px dashed black !important;} img.imageResizerChangedClass{z-index:300 !important;max-width:none !important;max-height:none !important;} img.imageResizerBoxClass{margin:auto; z-index:99999 !important; ; top:0; left:0; right:0; bottom:0; border:1px solid white; outline:1px solid black;} </style>- Edited by VD Tripathi Monday, September 2, 2013 11:02 AM
Monday, September 2, 2013 11:02 AM -
- Proposed as answer by Allen Li - MSFT Tuesday, September 3, 2013 6:20 AM
- Marked as answer by Allen Li - MSFT Thursday, September 12, 2013 2:23 PM
Monday, September 2, 2013 11:16 AM