[英]how to generate the Repository and model/entity classes with all CRUD operations using database-first apporach in C#
[英]Entity framework core (with mysql) model first apporach how to run custom query to get some count
我在我的存储库中使用实体框架核心获取不同的模型 get/add/update/delete 和 getall 现在对于一个场景,我需要纠正自定义查询以获取计数。 我找不到任何可以运行自定义查询的方法。 有任何身体使用过它。
创建数据传输对象 (DTO) 例如。
public class yourclassname
{
public string yourfiledname { get; set; }
public int count { get; set; }
}
那么你
public IActionResult gettop10staffcount()
{
var query = "your query";
var result = Context.yourclassname.FromSql(query).ToList();
return new ObjectResult(result);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.