I upgraded from .Net Core 2 to .Net 6. One of the errors that it caused was this:
Error CS1106 Extension method must be defined in a non-generic static class
It is happening on the public class BookController
line.
So I did some research on the Microsoft site and I removed the static
keyword from the LateFee
method.
But that doesn't fix the error.
Is there anything else I need to do?
Here is my class:
public class BookController
: LibraryController<BookClub, Books>
{
public BookController(BookConfig<BookClub> ctx)
: base(ctx)
{
}
private static bool LateFee(BookClub original, Books b)
{
return original.Date?.Id != b.CheckoutDate.TrimToNull();
}
}
Here is the parent class:
public class LibraryController()
[HttpPost("byLocation/{id}")]
public IActionResult PostBookRequest(this Int32 id)
{
using (var tran = Session.BeginTransaction()) {
foreach (var book in LibraryService.CreateHold(id)) {
Session.Save(book);
}
tran.Commit();
return NoContent();
}
}
Thanks!
public IActionResult PostBookRequest(this Int32 id)
从该行中删除this
,它在 .Net Core 2 中是一个语法错误,在 .Net6 中仍然是一个语法错误。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.