Reputation: 33
I've this code block and I want to know the type of object which "Any" method is called on that. For example in this scenario my expected result is DbSet
using (AppDbContext context = new AppDbContext() /*Inherited from DbContext of EntityFramework*/)
{
context.Products.Any(); // context.Products is type of DbSet<Product>
}
Or in this example:
new int[]{}.Any()
my expected result is int[]
Upvotes: 2
Views: 86
Reputation: 10201
Use SemanticModel.GetTypeInfo
.
For example, if you have a SyntaxNodeAnalysisContext context
and an ExpressionSyntax expression
, you would do
var type = context.SemanticModel.GetTypeInfo(expression, context.CancellationToken).Type;
Upvotes: 0
Reputation: 887453
Find the SyntaxNode
you're interested in, get its Compilation
, then call SemanticModel.GetSymbolInfo()
.
Upvotes: 1