0

I need your help to resolve this issue.

How to pass table name dynamically in linq to sql in C#.net?

public IntPol(DataClasses1DataContext DC, decimal value,string tableName)
{
}

tableName will change dynamically.

2

2 Answers 2

0

I don't believe this is going to be possible. At least not using traditional Ling-To-SQL. You could use the L2S Connection object, hard code a T-SQL statement, and pass that to SQL Server. But, in this case, you aren't really using L2S anymore.

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

Comments

0

If I understand the question correctly then you could do something like

public IntPol(DataClasses1DataContext DC, decimal value,string tableName)
{
  DC = new DataClasses1DataContext("yourConnString");
  var result = DC.Mapping.GetTables().SingleOrDefault(t => t.TableName.ToString() == tableName);
}

Or you could also do tableObject.GetType().Name but if type is dynamic might have to send Type tableType separately.

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.