4
LINQ to Entitiesは、IEntityインターフェイスを使用したEDMプリミティブまたは列挙型のキャストのみをサポートします
私は次の一般的な拡張メソッドを持っています: public static T GetById<T>(this IQueryable<T> collection, Guid id) where T : IEntity { Expression<Func<T, bool>> predicate = e => e.Id == id; T entity; // Allow reporting more descriptive error messages. try { entity = collection.SingleOrDefault(predicate); } catch (Exception ex) { throw new InvalidOperationException(string.Format( "There was an error retrieving …