I was able to resolve this by adding the class
generic type constraint to the extension method. I’m not sure why it works, though.
public static T GetById<T>(this IQueryable<T> collection, Guid id)
where T : class, IEntity
{
//...
}
More Related Contents:
- How do I apply OrderBy on an IQueryable using a string column name within a generic extension method?
- Internal .NET Framework Data Provider error 1025
- DbContext discard changes without disposing
- How to create LINQ Expression Tree to select an anonymous type
- Ignoring a class property in Entity Framework 4.1 Code First
- What difference does .AsNoTracking() make?
- What is the purpose of self tracking entities?
- The entity type is not part of the model for the current context
- How can I automatically filter out soft deleted entities with Entity Framework?
- LINQ to Entities does not recognize the method ‘Double Parse(System.String)’ method, and this method cannot be translated into a store expression
- Unable to update the EntitySet – because it has a DefiningQuery and no element exist
- Why is .Contains slow? Most efficient way to get multiple entities by primary key?
- Entity Framework – Code First – Can’t Store List
- Entity Framework/Linq EXpression converting from string to int
- How to compare only Date without Time in DateTime types in Linq to SQL with Entity Framework?
- Enable Migrations with Context in Separate Assembly?
- Why re-initiate the DbContext when using the Entity Framework?
- How do I create an expression tree calling IEnumerable.Any(…)?
- Entity Framework – Cannot convert lambda expression to type ‘string’ because it is not a delegate type
- Include with FromSqlRaw and stored procedure in EF Core 3.1
- How to filter data using Entity Framework in a way that DataGridView be editable and context track changes?
- Join and Include in Entity Framework
- Entity Framework Code Only error: the model backing the context has changed since the database was created
- How to compare only Date without Time in DateTime types?
- Set database timeout in Entity Framework
- Global setting for AsNoTracking()?
- Change db table name in EF4 (entity framework 4)
- The ObjectContext instance has been disposed and can no longer be used for operations that require a connection [duplicate]
- How to wrap Entity Framework to intercept the LINQ expression just before execution?
- Repository Pattern, POCO, and Business Entities