Skip to content

Instantly share code, notes, and snippets.

@natemcmaster
Last active October 28, 2015 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natemcmaster/a061f2a0a6d43ef14395 to your computer and use it in GitHub Desktop.
Save natemcmaster/a061f2a0a6d43ef14395 to your computer and use it in GitHub Desktop.

EF + Net Native

Limitations in Query

Query or projections with anonymous types

Queries that project or involve the use of anonymous types.

Examples
context.Posts.Select(g => new { u = g.Url, c = g.Count() });

Error Message

System.Reflection.MissingRuntimeArtifactException: MakeGenericMethod() cannot create this generic method
 instantiation because the instantiation was not metadata-enabled: 
'Microsoft.Data.Entity.Storage.IDatabase.CompileQuery<<>f__AnonymousType39<T>>(Remotion.Linq.QueryModel)'
context.Posts.GroupBy(p => p.Id, p=> new { p.BlogId })

Error Message

System.Reflection.MissingRuntimeArtifactException: MakeGenericMethod() cannot create this generic method instantiation 
because the instantiation was not metadata-enabled: 
'Microsoft.Data.Entity.Query.Internal.LinqOperatorProvider._GroupBy<Microsoft.Data.Entity.Storage.ValueBuffer,System.String,<>f__AnonymousType55<T>>()'

Queries against shadow properties

context.Posts.Where(p => EF.Property<string>(p, "DraftTitle") == "New Post")

Error Message

System.InvalidOperationException: The EF.Property<T> method may only be used within LINQ queries.

Queries that use join

var posts = from c in comments
                join p in ps on c.PostId equals p.CommentId into posts
                from p in posts
                select p

Error Message

System.Reflection.MissingMetadataException: 'System.Collections.Generic.IEnumerable<Microsoft.Data.Entity.Query.EntityQueryModelVisitor.TransparentIdentifier<T1,System.Collections.Generic.IEnumerable<T2>>>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment