public class MovieTotal:DbContext
{
public DbSet<Movie> Movies { get;set; }
public DbSet<Person> Persons { get; set;}
protected override void OnModelCreating(System.Data.Entity.ModelConfiguration.ModelBuilder modelBuilder)
{
Movie mov = new Movie();
modelBuilder.Entity<Movie>().Property(GetPropert("MovieName")).HasColumnName("Actors");
}
public System.Linq.Expressions.Expression<Func<Movie,string>> GetPropert(string properName)
{
// Func<Movie, string> dele =
System.Linq.Expressions.Expression<Func<Movie, string>> exp = k => (string)(typeof(Movie).GetProperty(properName).GetValue(k, null));
return exp ;
}
public string GetColumnName(string value)
{
return "Actors";
}
public MovieTotal()
{
this.Database.Connection.ConnectionString = @"Data Source=(local);Initial Catalog=MovieTotal6;Integrated Security=SSPI;";
}
}
这是错误消息:
表达式 'k => Convert(Movie.GetProperty(value(MovieTotal+ <>c__DisplayClass0).properName).GetValue(k, null))' 不是有效的属性表达式。它必须采用“e => e.Property[.Property]”的形式。