Why are my columns with data annotations not showing when using Entity Framework

I have a class that looks like this:

public class Analyst
{
    [Column("Internal_ID")]
    public int ID { get; set; } // if this is named like the column, it works
    [Column("DisplayName")]
    public string Name { get; set; }
}

This object is populated like this (this next part is in the class that inherits from DbContext):

public List<T> ExecProc<T>(string proc, Dictionary<string, object> params)
{
        var parms = new List<SqlParameter>();
        var sql = new StringBuilder();
        sql.Append(sproc.StoredProcedure);
        sql.Append(" "); //  a space, that all it is
        foreach (var key in sproc.Parameters.Keys)
        {
            sql.Append(string.Format("{0},", key));
            parms.Add(new SqlParameter(key, sproc.Parameters[key]));
        }
        if (sql[sql.Length - 1] == ',') // removing the trailing ,
        {
            sql.Remove(sql.Length - 1, 1);
        }
        return Database.SqlQuery<T>(sql.ToString(), parms.ToArray()).ToList();
}

The returned list contains the correct number of rows (or objects in this case), but none of the properties are filled with values. If proc returns 200 rows, then I get 200 objects in the List, but none of them matter.

, [Column ( "name" )] . , , , . - , ? , - .

: Visual Studio 2010 Ultimate SP1,.Net 4 SP1, EF 4.2.0 ( EF 4.3). , .

+3
1

, . Database.SqlQuery DbContext.

SQL-, . , , , , .

, sql, .

+8

All Articles