Create Entities in-memory from Autoentities#3129
Create Entities in-memory from Autoentities#3129RubenCerna2079 wants to merge 22 commits intomainfrom
Conversation
1972a8f to
2f256e4
Compare
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
|
||
| _entityNameToDataSourceName = new Dictionary<string, string>(); | ||
| if (Entities is null) | ||
| if (Entities is null && this.Entities.Entities.Count == 0 && |
There was a problem hiding this comment.
This condition will throw NullException
There was a problem hiding this comment.
I am not following why this would throw a NullException
There was a problem hiding this comment.
please rename Entities to entities since its a function argument
| return _entityNameToDataSourceName.TryAdd(entityName, this.DefaultDataSourceName); | ||
| } | ||
|
|
||
| public bool TryAddEntityNameToDataSourceName(string entityName, string autoEntityDefinition) |
There was a problem hiding this comment.
nit: rename the function to inform we are adding entity name from AutoentityDefinition
| /// <returns>DataSourceName</returns> | ||
| public string GetDataSourceNameFromAutoentityName(string autoentityName) | ||
| { | ||
| CheckAutoentityNamePresent(autoentityName); |
There was a problem hiding this comment.
instead of 2 functions, why cant we use TryGet function? if false, you can throw exception.
| { | ||
| await Task.CompletedTask; | ||
| RuntimeConfig runtimeConfig = _runtimeConfigProvider.GetConfig(); | ||
| Dictionary<string, Entity> entities = new(); |
There was a problem hiding this comment.
define entities where its needed. Since autoentities could still be null, defining here is pre-mature if we are just going to return.
|
|
||
| if (runtimeConfig.IsRestEnabled) | ||
| { | ||
| _logger.LogInformation("[{entity}] REST path: {globalRestPath}/{entityRestPath}", entityName, runtimeConfig.RestPath, entityName); |
There was a problem hiding this comment.
Why is only Rest information being logged?
| foreach ((string autoentityName, Autoentity autoentity) in autoentities) | ||
| { | ||
| int addedEntities = 0; | ||
| JsonArray? resultArray = await QueryAutoentitiesAsync(autoentity); |
There was a problem hiding this comment.
when querying, are we asking the right datasource to query from? How is that information being passed to QueryAutoentitiesAsync?
| if (GetDatabaseType() == DatabaseType.MSSQL) | ||
| { | ||
| await GenerateAutoentitiesIntoEntities(); | ||
| await GenerateAutoentitiesIntoEntities(new Dictionary<string, Autoentity>(Autoentities)); |
There was a problem hiding this comment.
why is the need to create new dictionary of Autoentities here? cant you simply pass the Readonly dictionary?
|
|
||
| Assert.IsTrue(loader.TryLoadConfig("dab-config.json", out RuntimeConfig runtimeConfig), "Should successfully load config"); | ||
| Assert.IsTrue(runtimeConfig.SqlDataSourceUsed, "Should have Sql data source"); | ||
| Assert.AreEqual(expectedEntities, runtimeConfig.Entities.Entities.Count, "Default datasource should be of root file database type."); |
There was a problem hiding this comment.
The error message here seems to be not accurate.
| "stocks_view_selected": { | ||
| "source": { | ||
| "object": "stocks_view_selected", | ||
| "type": "view", |
There was a problem hiding this comment.
Can you also test by naming the child data sources explicitly? I dont know if we provide the datasource name in the sample files or rely on the default one.
|
|
||
| Assert.IsTrue(loader.TryLoadConfig("dab-config.json", out RuntimeConfig runtimeConfig), "Should successfully load config"); | ||
| Assert.IsTrue(runtimeConfig.SqlDataSourceUsed, "Should have Sql data source"); | ||
| Assert.AreEqual(expectedEntities, runtimeConfig.Entities.Entities.Count, "Default datasource should be of root file database type."); |
There was a problem hiding this comment.
does this runtimeConfig.Entities.Entities.Count include entities matching from all the data source files - including the ones that matched from autoentities ?
Aniruddh25
left a comment
There was a problem hiding this comment.
Waiting on addressing some questions..
Why make this change?
We need to generate all the entities from the autoentities properties. In order to do this we need to use the query that was previously created and, add the newly generated entities into the runtime so the user can use them.
What is this change?
MsSqlMetadataProvider.cs: Finish creating theGenerateAutoentitiesIntoEntitiesfunction so that it uses the query to receive all of the tables and turn them into entities inside the runtimeConfig.RuntimeConfig.cs: Create new function that adds the new entities to the runtimeConfig. And also change the runtimeConfig to allow for theentitiesproperty to be missing if the user decides to use theautoentitiesproperty.How was this tested?