-2

I'm trying to use table name as variables

Base on this question here

I'm able to do it in some cases but in this one:

var usersId = db[tableNameLabel].All().Select(db[tableNameLabel].userid,
db[tableNameLabel].rating.Count().As("Count"));

I get the next error:

"The best overloaded method match for 'Simple.Data.DataStrategy.this[string]' has some invalid arguments"

Update:

Fixed it.

var usersId = db[tableNameLabel.Text].All().Select(db[tableNameLabel.Text].userid,
db[tableNameLabel.Text].rating.Count().As("Count"));

Needed tableNameLabel.Text.

Thanks

Community
  • 1
  • 1

1 Answers1

0

The only place in the code in the question where you use an indexer is in this expression:

db[tableNameLabel]

The error message:

he best overloaded method match for 'Simple.Data.DataStrategy.this[string]' has some invalid arguments

is noting an indexer, DataStrategy.this[string].

Clearly the compiler doesn't think that tableNameLabel is of type string, so check out that variable and see what it is.

Perhaps you meant to dereference a property off of that variable?

Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825