4
LINQ ke Entitas hanya mendukung casting EDM primitif atau jenis enumerasi dengan antarmuka IEntity
Saya memiliki metode ekstensi umum berikut: 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( …