Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I am using Linq to Entities in my WPF project. As per the logic i need to select table name dynamically from the UI. this means, I need to pass Table name to the Function and using this.

Code as follows.::

XML
public List<Records> GetNonDuplicateRecords()
          {

              ThreeEntities threeentities = new ThreeEntities();

              List<Records> recs = (from p in threeentities.UE_Aetna

                                    select new Records
                                    {
                                        _claimNumber = p.ClaimNumber,
                                        _firstname = p.PatientFirstName,
                                        _lastname = p.PatientLastName,
                                        _client = p.Client
                                    }).ToList<Records>();

              return recs;
          }


Instead of above function GetNonDuplicateRecords() with no arguments i will pass GetDuplicateRecords(string TableName) then in Linq query it should use as following.


XML
public List<Records> GetNonDuplicateRecords(string tableName)
          {

              ThreeEntities threeentities = new ThreeEntities();

              List<Records> recs = (from p in threeentities.TableName "Should use this"

                                    select new Records
                                    {
                                        _claimNumber = p.ClaimNumber,
                                        _firstname = p.PatientFirstName,
                                        _lastname = p.PatientLastName,
                                        _client = p.Client
                                    }).ToList<Records>();

              return recs;
          }


Is there any possibility for this in Linq to Entities.

Thanks in advance.

chowdary.
Posted

1 solution

 
Share this answer
 
Comments
Zoltán Zörgő 30-Aug-12 12:16pm    
As I know, there is no GetTable for LINQ to Entities :(
Kuthuparakkal 31-Aug-12 9:12am    
:(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900