IN SS 8.4.2 we use aliasses like below. Upgrading to SS 8.5.2 break aliases.
Here is a copy of the query:
var query = db.From<Company>(db.TableAlias("c"))
.Join<BranchCompanies>((c, b) => c.Id == b.CompanyId, db.TableAlias("b"))
.Join<CompanyInformation>((c, ci) => c.Id == ci.CompanyId, db.TableAlias("ci"))
.Join<CompanyCompanyTypeMapping>((c, m) => c.Id == m.CompanyId, db.TableAlias("m"))
.Join<CompanyCompanyTypeMapping, ServiceModel.Types.CompanyType>((m, t) => Sql.TableAlias(m.CompanyTypeId, "m") == t.Id, db.TableAlias("t"))
.Where<Company>(c => c.IsActive == true && c.CountryId == countryId)
.Where<BranchCompanies>(b => Sql.TableAlias(b.IsActive, "b") == true && Sql.TableAlias(b.StartDate, "b") <= inceptDate && Sql.TableAlias(b.EndDate, "b") >= inceptDate)
.Where<CompanyInformation>(ci => Sql.TableAlias(ci.IsActive, "ci") == true && Sql.TableAlias(ci.StartDate, "ci") <= inceptDate && Sql.TableAlias(ci.EndDate, "ci") >= inceptDate)
.Where<ServiceModel.Types.CompanyType, BranchCompanies>((t, b) => Sql.TableAlias(t.IsActive, "t") == true && Sql.TableAlias(t.CompanyTypeName, "t") == "FINANCE" && (branchId == null || Sql.TableAlias(b.BranchId, "b") == branchId) && (groupId == null || Sql.TableAlias(b.GroupId, "b") == groupId))
.Select<Company, BranchCompanies, CompanyInformation, CompanyCompanyTypeMapping>((c, b, ci, m) => new
{
c.Id,
CompanyCompanyTypeId = Sql.TableAlias(m.Id, "m"),
c.CompanyCode,
c.CompanyName,
c.CountryId,
c.IsActive,
CompanyLogo = Sql.TableAlias(ci.CompanyLogo, "ci"),
c.FinanceCompanyName,
FinanceStatusValue = string.Empty,
FinanceStatusId = (long?)default,
FinanceStatusNotes = string.Empty,
FinanceAccountNumber = string.Empty,
DICAmount,
BankersName = string.Empty,
BankersOfficeTelephoneCode = string.Empty,
BankersOfficeTelephoneNumber = string.Empty,
BankersMobileNumber = string.Empty,
BankersEmailAddress = string.Empty,
SortKey = Sql.TableAlias(b.SortKey, "b"),
ShowLogoOnFinanceAppPDF = c.ShowLogoOnFinanceAppPDF ?? false,
ShowLogoOnFinanceAppList = c.ShowLogoOnFinanceAppList ?? false
});
var companiesAfterFirstSelect = await db.SelectAsync<FinanceCompany>(query);
here is the stack strace string: at ServiceStack.OrmLite.OrmLiteExecFilter.Exec[T](IDbConnection dbConn, Func2 filter) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteExecFilter.cs:line 140 at SeritiApi.ServiceLogic.Services.FinanceApplicationDataService.GetFinanceCompaniesAsync(Nullable
1 groupId, Nullable`1 branchId, Int64 countryId, Int32 transactionId) in C:\Users\Eric Mugo\Clients\Seriti\SeritiApi\SeritiApi.ServiceLogic\Services\FinanceApplicationDataService.cs:line 111
System.Data.SqlClient.SqlException
HResult=0x80131904
Message=Incorrect syntax near ‘=’.
Incorrect syntax near ‘b’.
Incorrect syntax near ‘ci’.
Incorrect syntax near ‘t’.
Source=Core .Net SqlClient Data Provider
StackTrace:
at ServiceStack.OrmLite.OrmLiteExecFilter.d__6`1.MoveNext()