Assume having these models first:
Method that has one OriginalCode
OriginalCode that has many Mutants
Mutant that has many ParseSubTrees
Now when querying on Method I want the other being loaded. So I have the following:
Method targetMethod = dBContext.Methods
.Include(me => me.OriginalCode)
.ThenInclude(oc => oc.Mutants)
.FirstOrDefault(me => me.Id == id);
and the next step is to include additionally the ParseSubTree. But the thing is that I can't access it. See the following Image:
the problem is "mu is a list instead of being an object reference"!
Where is my mistake!
TG.
This is a known Intellisense issue with the ThenInclude overload for collection type navigation properties, tracked by the Completion missing members of lambda parameter in fault tolerance case #8237 Roslyn GitHub issue.
Until it gets fixed, simply type the name of the property and it will compile successfully and work as expected.
.ThenInclude(mu => mu.ParseSubTrees)
Update: Now it's even specifically mentioned in the Including multiple levels
section of the EF Core documentation:
Note
Current versions of Visual Studio offer incorrect code completion options and can cause correct expressions to be flagged with syntax errors when using the ThenInclude method after a collection navigation property. This is a symptom of an IntelliSense bug tracked at https://github.com/dotnet/roslyn/issues/8237. It is safe to ignore these spurious syntax errors as long as the code is correct and can be compiled successfully.
In my case there was a conflict between the namespaces System.Data.Entity and Microsoft.EntityFrameworkCore. Just delete the first using line.
Related
I recently upgraded a relatively old System TYPO3 4.7 => 6.2.
I changed alot of namespaces/imports etc. and fixed stuff here and there. After the system was stable I made some changes in the extension builder and added some new fields.
I had to change some code in some files that threw errors but after that I was able to successfully save in the extension builder.
It added the correct classes,attributes and actions but now the system shows me this error:
1247602160: Table 'keepins_upgrade.tx_extbase_persistence_objectstorage' doesn't exist
Usually this error is related to models that are mapped incorrectly in the typoscript file but this seems different.. any suggestions?
Shot from the hip: you have one or more properties in your domain model which is annotated incorrectly - so it is read as a 1:1 relation to ObjectStorage, not a 1:n to a collection of another object. Or, less likely given your previous version, you've annotated a setter method or controller action so it requires an instance of ObjectStorage, but neglected to add PHPDOC that defines the true expected child type or is somehow else invalid or not connected to the right property.
I am working in VS 2015 solution with an MVC 5 project and a code library project using EF 6.1. I have redone the entire project from a previous version in VS 2013 hoping it would resolve this problem, but no luck. I am just trying to eager load a child with grandchildren. I tried this:
Test t = db.Tests
.Include("TestsRemoteOBD")
.Include("TestsRemoteOBD.TestsRemoteOBDDtcs")
.FirstOrDefault();
and this:
Test t = db.Tests
.Include(i=>i.TestsRemoteOBD)
.Include(i=>i.TestsRemoteOBD.Select(s=>s.TestsRemoteOBDDtcs))
.FirstOrDefault();
Include using the string works for the child, but not the grandchildren. And with the 2nd query, I'm getting this error:
'TestsRemoteOBD' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'TestsRemoteOBD' could be found (are you missing a using directive or an assembly reference?)
I've seen the same question resolved by adding "using System.Data.Entity;", but I had done that a long time ago. No help. What else could I be missing?
Thanks!
Thanks so much, to all those who commented. I would have been banging my head for another day, at least. The way I had written the second statement would have worked fine if the parent [Tests] had a 1-to-many relationship with [TestRemoteOBD], but since the latter was not a collection, there was no 'Select' defined. I have not tested, but I believe it should be something like:
Test t = db.Tests
.Include(i=>i.TestsRemoteOBD)
.Include(i=>i.TestsRemoteOBD.TestsRemoteOBDDtcs)
.FirstOrDefault();
Bump. Found this and thought I'd throw in my own research.
Microsoft's
Documentation
states: To include a reference and then a reference one level down: query.Include(e => e.Level1Reference.Level2Reference)
-- but this doesn't seem to work under even the simplest use case. Executing the query with a .ToList() does not actually include anything. Smells like an obvious bug to me!
I can see 2 workarounds.
First, as Ben here suggests, you can manually iterate over the entities to force EF to load them.
Second, if scoping permits, you can forget the 'using' block and keep a more permanent instance of the dbcontext as a class member so that it's still available, not disposed (System.ObjectDisposedException), when the members are accessed.
The element 'Dependent' in namespace 'http://schemas.microsoft.com/ado/2008/09/edm' has incomplete content.
List of possible elements expected: 'PropertyRef' in namespace 'http://schemas.microsoft.com/ado/2008/09/edm'.
I'm using EF4, db first. The error links to an association within the edmx file, unfortunately I am not very experienced with EF Database First (I have previously been using code first) however this error really does not seem to make much sense anyway.
I am guessing a little here but...try regenerating your edmx?
I'm trying to set up a route in the Playframework 2.0 (Scala) that includes optional parameters in the query string, following the examples in the documentation:
GET /my/path controllers.foo.Bar.list(offset: Int ?= 0, limit: Int ?= 20)
However when compiling, I get the following error message:
object controllers.foo.Bar does not take parameters
I made sure that the controllers.foo.Bar.list method does in fact take two Ints as parameters. One key observation (I hope) may be that this used to work previously, when I had the Controller class directly in the controllers package, i.e.
controllers.Bar.list
But it ceased working as soon as I introduced a "foo" subpackage in Controllers.
Any input on what I'm doing wrong highly appreciated!
UPDATE: Sorry - I did some more experimenting and it seems the reason is something entirely different (d'oh). In my concrete case, my controller class was
controllers.foo.List.list
and that seemed to cause a name clash. Renaming to something else ("FooList") solved the issue.
For anyone discovering this question, it seems very likely that this was due to a bug in the Play Framework.
You can follow its progress on the issue tracker ticket.
We have a long running workflow which uses SQL tracking service (.Net WF 4.0). In the next update, we would like to introuduce a public property in one of the arguments of the workflow. Since this is breaking change, the persisted workflow inatances throw the following error on re-loading:
System.Runtime.DurableInstancing.InstancePersistenceCommandException: The execution of the InstancePersistenceCommand named .. LoadWorkflow was interrupted by an error.
InnerException: System.Runtime.Serialization.SerializationException: 'Element' '_x003C_BookmarkName_x003E_k__BackingField' from namespace '...' is not expected. Expecting element '....'
I understand this is a typical versioning issue and one of the recommendations I noticed on some of the sites is to override OnActivityExecutionContextLoad method and fill in the missing values. But I am not sure where and how to do this! OnActivityExecutionContextLoad is declared in System.Workflow.ComponentModel.Activity (.Net 3.5?) whereas what we have is a code-based top-level custom activity derived from System.Activities.NativeActivity (which receives the argument in question). Can something be done in this class to initialize the missing property of the argument?
All suggestions are welcome :)