[英]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.