【发布时间】:2012-08-15 06:34:40
【问题描述】:
我使用的是 Entity Framework 4.3.1 Code First,我有类似以下内容:
class Program
{
static void Main(string[] args)
{
// get LogEntry with id x..
}
}
public class MyContext : DbContext
{
public DbSet<Log> Logs { get; set; }
}
public class Log
{
public int LogId { get; set; }
public ICollection<LogEntry> LogEntries { get; set; }
}
public class LogEntry
{
public int LogEntryId { get; set; }
}
在给定整数 LogEntryId 的情况下,获取 LogEntry 对象的最佳方法是什么?是否可以不通过Log.LogEntries 属性直接获取实体?
【问题讨论】:
标签: c# entity-framework-4 .net-4.0 ef-code-first