Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with queries in the ifc structure at esent database #577

Open
DialPawlowski opened this issue Sep 13, 2024 · 3 comments
Open

Problem with queries in the ifc structure at esent database #577

DialPawlowski opened this issue Sep 13, 2024 · 3 comments

Comments

@DialPawlowski
Copy link

Hello.

I have a Problem after the update from Version 5.1.341 to 6.0.445. After the update I had a problem with an ifc file grater 100 MB.

 IfcModel = IfcStore.Open(fileInfo.FullName, null, null, (_, _) => { progressManager.IncrementProgress(); });

Search function no longer returned any results with the ifc database in the esent database.

Here is an example for one search:

ifcStorey.Model.Instances
                          .Where<IIfcRelContainedInSpatialStructure>(relation=> relation.RelatingStructure == ifcStorey)
                          .SelectMany(subrel => subrel.RelatedElements);

The comparison from relation.RelatingStructure and ifcStorey does not work in the new version. At this point, only Equals would work.

If I open the IFC in memory, the queries will work as usual. (ifcDatabaseSizeThreshHold -1)

 IfcModel = IfcStore.Open(fileInfo.FullName, null, -1, (_, _) => { progressManager.IncrementProgress(); });

Is there any Problem with the Esent Database? Looks like querying an object always returns a new instance.
Or is it normal that a IfcStorey has a new instance in the IIfcRelContainedInSpatialStructure.RelatingStructure property?

@DialPawlowski DialPawlowski changed the title Probblem with queries in the ifc structure at esent database Problem with queries in the ifc structure at esent database Sep 13, 2024
@martin1cerny
Copy link
Member

Hi @DialPawlowski , thank you for opening this thread. ESENT implementation is trying to be as lightweight as possible, so it doesn't keep references to objects. As a result, the actual object you got earlier and the one you are comparing have identical shape, but are fundamentally different objects with different object reference. At the same time, you use the interface to retrieve the data, but we can't override the equality operators for interfaces to handle this case.

The solution is either to use entity caching of the IModel (using var cache = model.BeginEntityCaching()), or use the object.Equals() function which is overriden to handle this case, or use entity.EntityLabel as a means of object identity, or you can use MemoryModel which keeps the full object graph in memory with all objects being unique. It all depends on your scenario. But I agree this can get very confusing.

@DialPawlowski
Copy link
Author

Thanks for your response.
I tried to use the entity cach using var cache = model.BeginEntityCaching() but this works not for Esent DB. In that case the cache is a DummyCache and the cache is not in use.
Is this normal or have I done something wrong?

@martin1cerny
Copy link
Member

martin1cerny commented Oct 8, 2024

I'm sorry, I haven't used ESENT for a long time. Actually, we use an internal SQLite IModel implementation for most of the tasks at the moment. You can also rewrite your query to use the object equality operator this way:

ifcStorey.Model.Instances
    .Where<IIfcRelContainedInSpatialStructure>(relation=> relation.RelatingStructure.Equals(ifcStorey))
    .SelectMany(subrel => subrel.RelatedElements);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants