Search code examples
asp.net-coreasp.net-web-apiblazor-server-sideblazor-webassemblyc#-7.0

i get error error CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback' when make search


I work on the blazer web app .NET core 7 Server Side. I face an error.

error CS1503: Argument 2: cannot convert from 'method group' to 'EventCallback'

How can I solve this error?

I try clicking button to search for data but I get the error cannot convert from 'method group' to 'EventCallback'

Dashboar.Razor
<button type="button" class="btn btn-primary pull-right" style="display: flex;direction: ltr;" @onclick="Search">
<span class="bi bi-plus-circle" style="margin-right: 5px;"></span>Filter
</button>

DashboarBase.cs

public List<ApplicationDto> Search()
{
    isLoading = true;
    
    ApplicationsFilterDto obj = new ApplicationsFilterDto();
    obj.serverID = serverID;
    obj.ownerId = ownerId;
    obj.databaseId = databaseId;
    isLoading = false;
    AllApplicationsList = _EmplyeeService.ListOfApplications(obj);
    return AllApplicationsList;
}

service

IEmployeeService 

List<ApplicationDto> ListOfApplications(ApplicationsFilterDto obj);

EmployeeService

function return ApplicationDto

public List<ApplicationDto> ListOfApplications(ApplicationsFilterDto emp)
{
    var appList = _context.Database.SqlQuery<ApplicationDto>($"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}").ToList(); 
    
    return  appList;  
}

filter model

public class EmployeeFilterDto
{
    public string Department { get; set; }
    public DateTime? FromDate { get; set; }
    public DateTime? ToDate { get; set; }
}

return model

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; }
}

Solution

  • I think you're missing the event arguments and have incorrect return type. The following should work:

    public void Search(MouseEventArgs e)
    {
      // ...
    }