.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I work on .net core 7 entity framework core . I get error when run my application on this function
error say cannot convert from 'string' to 'System.FormattableString'
public List<ApplicationDto> ListOfApplications(ApplicationsFilterDto emp)
{
var appList = _context.Database.ExecuteSql($"select ApplicationsData.ApplicationID as ApplicationId,Application_Name as ApplicationName,CommonName,d.DetailsName as TypeOfApplication,AccessType,d.DetailsName Criticality,o.OwnerName as ApplicationOwner,DRRequired,se.[DB_Name] as [DataBase] from ApplicationsData left join [dbo].[Details] d with(nolock) on d.ID=ApplicationsData.ApplicationType and d.HeaderId=6 left join [dbo].[Details] d2 with(nolock) on d2.ID=ApplicationsData.Criticality and d2.HeaderId=7\r\nleft join dbo.[Owner] o with(nolock) on o.ApplicationId=ApplicationsData.ApplicationID\r\nleft join dbo.[DataBase] se with(nolock) on se.ServerID=ApplicationsData.ServerId where ApplicationsData.ServerId=" + emp.serverID + " OR SE.[DBID]=" + emp.databaseId + " OR o.OwnerId=" + emp.ownerId + "");
return appList;
}
return model as below :
public class ApplicationDto
{
public int ApplicationId { get; set; }
public string ApplicationName { get; set; }
public string CommonName { get; set; }
public string TypeOfApplication { get; set; }
public string AccessType { get; set; }
public string Criticality { get; set; }
public string DataBase { get; set; }
public string BSSVServer { get; set; }
public string DRRequired { get; set; }
public string ApplicationOwner { get; set; }
}
filter model I use it
public class ApplicationsFilterDto
{
public int serverID { get; set; }
public int ownerId { get; set; }
public int databaseId { get; set; }
}
Try modifying the where part:
var appList = _context.Database.ExecuteSql($"select . . . where ApplicationsData.ServerId={emp.serverID} OR SE.[DBID]={emp.databaseId} OR o.OwnerId={emp.ownerId}");