문제

I want to implement a function that accepts a DbSet (non-generic), a string, and object, and returns DbSet. something like the following pseudu:

public static DbSet Any(DbSet set, string propertyName, objectParameter)
{
  var tableName = set.TableName;
  var columnName = set.GetColumnNameForProperty(propertyName); 
  var query = string.Format("SELECT TOP(1) {0} FROM {1} WHERE {0} = {2}",
                columnName, 
                tableName,
                objectParameter);
}

I think that SQL query is enough since I'll be able to execute it directly on the Database (context.Database.ExecuteSql).

What I want to do is get the table name from the given DbSet, then the column name in the database.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top