0

I need to get column name and value from a table which I know only the name. I try lot of stuff but without success.

I use this for get my table :

var table = oSession.ctx.GetType()
                       .GetProperty("country")
                       .GetValue(oSession.ctx, null);

I'm lock with that I can't retrieve the informations of my columns .. Perhaps I have already try this :

List<string> columnsNames = table.GetType().GetFields().Select(field => field.Name).ToList();

Thx for your help..

2 Answers 2

2

Use ((IQueryable)table).ElementType.GetProperties() as a starting point. Also you can get some ideas from Dynamic LINQ query to get Field value from Database

Sign up to request clarification or add additional context in comments.

Comments

0

you can probably try using GetProperties() table.GetType().GetProperties().Where(p => !(p.GetMethod.IsVirtual || p.GetIndexParameters().Length > 0)).ToList()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.