Page 1 of 1

Table names with dots (v2023)

Posted: Mon Feb 06, 2023 12:09 am
by darkdragon

Error on another converted project:

SqlException: Invalid object name 'dbo.[Application.UserLevels]'.
Microsoft.Data.SqlClient.SqlCommand+<>c.<ExecuteDbDataReaderAsync>b__208_0(Task<SqlDataReader> result)
...
Dapper.SqlMapper.QueryAsync<T>(IDbConnection cnn, Type effectiveType, CommandDefinition command) in SqlMapper.Async.cs
SqlKata.Execution.QueryFactory.GetAsync<T>(Query query, IDbTransaction transaction, Nullable<int> timeout, CancellationToken cancellationToken)
SqlKata.Execution.QueryExtensions.GetAsync<T>(Query query, IDbTransaction transaction, Nullable<int> timeout, CancellationToken cancellationToken)
ASPNETMaker2023.Models.IQVIAeLearning+AdvancedSecurityBase.SetupUserLevels() in AdvancedSecurityBase.cs
+
            UserLevel = (await tbl.GetQueryBuilder().Select($"{Config.UserLevelIdField} as Id", $"{Config.UserLevelNameField} as Name").GetAsync<UserLevel>()).ToList();
ASPNETMaker2023.Models.IQVIAeLearning+AdvancedSecurityBase.SetupUserLevel() in AdvancedSecurityBase.cs

This query is run against the DB and it fails, obviously:

SELECT [apul_in_level_id] AS [Id], [apul_vc_level_name] AS [Name] FROM [dbo].[[Application].[UserLevels]]]

We have multiple projects where we use dots in the name of the tables in order to group them logically


Re: ANM 2023, doesn't handle tables with dots

Posted: Mon Feb 06, 2023 7:31 am
by Webmaster

If you are a registered user, please send your project/database to the support email for further checking. Thanks.


Re: ANM 2023, doesn't handle tables with dots

Posted: Mon Feb 06, 2023 5:37 pm
by darkdragon

I will submit a stripped version to support.

Thanks.


Re: Table names with dots (v2023)

Posted: Mon Feb 06, 2023 10:43 pm
by MichaelG

Avoid using dot in table names. Dots are used to separate schema and table name, using dots in table name may not be good practice because it may cause confusions in some packages (even it is possible to use square brackets to quote such table names).


Re: Table names with dots (v2023)

Posted: Mon Feb 06, 2023 11:36 pm
by darkdragon

We can't refactor a database just because it's not a "best practice" as long as it's not forbidden by SQL Server.
The same goes for spaces or even reserved keywords, which is why we have square brackets [] to delimit identifiers.

Usually, these types of databases are carried over years in medium/large companies and we simply cannot refactor them, especially in those cases where they are inherited from third-party vendors, etc.