Table names with dots (v2023)

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
darkdragon
User
Posts: 148

Table names with dots (v2023)

Post 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


Webmaster
User
Posts: 9425

Post by Webmaster »

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


darkdragon
User
Posts: 148

Post by darkdragon »

I will submit a stripped version to support.

Thanks.


MichaelG
User
Posts: 1095

Post 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).


darkdragon
User
Posts: 148

Post 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.


Post Reply