tags:

views:

82

answers:

4
+1  Q: 

Table Filed

hi

My code that can get tablename in linq query is:

     Dim TY As Type = (From T In DB.Mapping.GetTables()
                       Where T.TableName = tableN
                       Select T.RowType.Type).SingleOrDefault
     Dim Table As ITable = DB.GetTable(TY)
     Dim mq = From t In Table Select t

tableN get from another form. I want to access the fileld of Table and use in linq query .how?

for example:

Dim mq = From t In Table Select t.Code

please help me

+1  A: 

Try using extension methods instead:

Dim mq = Table.Select( Function(t) t.Code );
tvanfosson
A: 

I don't know the the name and type of my selected table until query executed. how Can I use this Extension?

A: 

Hi Moghadas

I've changed your final select to look something like this:

Dim mq = From t In Table.OfType<XXX> Select t.Code

The only thing that you'll need to know now is what type is in that table. Does this help?

Ray Booysen
A: 

Can you do something similar to this?

Dim p As System.Reflection.PropertyInfo = Table.GetType().GetProperty("Code")
Dim mq = From t in Table Select p.GetValue(t)
BlueMonkMN