方法没有重载需要0个参数 [英] no overload for method takes 0 arguments

查看:185
本文介绍了方法没有重载需要0个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在.cshtml



This is in .cshtml

@foreach (var certi in repo.SearchBoardCertificationRepo())
                    {
                        <tr>
                            <td>@certi.examdate</td>
                            <td>@certi.regopendate</td>
                            <td>@certi.regclosedate</td>
                            <td>@certi.maxseats</td>
                            <td>@certi.current_seat</td>
                            <td>@certi.max_ecs</td>
                            <td>@certi.ecs_seats</td>
                            <td>@certi.ecs_cases</td>
                            <td>@certi.ice_fee</td>
                            <td>@certi.ice_Main</td>
                            <td>@certi.ice_in</td>                           
                        </tr>
                    }





和我的控制器方法是





and my controller method is

public IList<BoardCertificate> SearchBoardCertificationRepo(BoardCertificate board_certification)
      {
          return _database.Fetch<BoardCertificate>("select * from BoardCertificates where lastname ='" + board_certification.lastname + "'  ");
      }







和我在@foreac上的错误,错误是方法没有重载需要0个参数

实际上我只想在页面上显示来自控制器的数据。



谢谢。




and my error on above at @foreac, The error is "no overload for method takes 0 arguments".
Actually i want simply display data on page which from getting in controller.

Thanks.

推荐答案

您需要将BoardCertificate类型的对象传递给SearchBoardCertificationRepo方法



You need to pass an object of type BoardCertificate to your SearchBoardCertificationRepo method

@foreach (var certi in repo.SearchBoardCertificationRepo(cert))





其中cert 是BoardCertificate类型的东西。我们没有你的代码或知道你有什么或你的方法做什么,所以不可能给出任何更具体的建议。



看起来你的方法只搜索姓氏所以如果你知道姓氏要搜索什么,这应该有效





where "cert" is something of type BoardCertificate. We don't have your code or know what you have available or what your methods do so it is impossible to give any more specific advice.

It looks like your method just searches on surname so if you know what the surname is to search on, this should work

@foreach (var certi in repo.SearchBoardCertificationRepo(new BoardCertificate{lastname="Smith"} ))





作为旁注,您的代码可能会对SQL注入攻击开放。



As a side note, your code might be open to SQL injection attacks.


查看你的第二个代码块:方法 SearchBoardCertificationRepo 接受一个参数: BoardCertificate board_certification



查看顶部代码块:您使用零参数调用 SearchBoardCertificationRepo 。您需要指定一些 BoardCertificate 作为参数。我不能告诉你哪一个或它应该来自哪里 - 这是你应该知道或者必须弄明白的东西。
Look at your second code block: The Method SearchBoardCertificationRepo takes one argument: BoardCertificate board_certification

Look at the top code block: You're calling SearchBoardCertificationRepo with zero arguments. You need to specify some BoardCertificate as argument. I can't tell you which one or where it should come from - that's something you should know or would have to figure out.


这篇关于方法没有重载需要0个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆