如何在多个密钥getbyid存储库模式上使用动态数据类型 [英] How to use dynamic datatype on more than one key getbyid repository pattern
本文介绍了如何在多个密钥getbyid存储库模式上使用动态数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题
如何在多个密钥GetByID存储库模式上使用动态数据类型?
public T GetById (int Id)
{
return dbSet.Find(Id);
}
和接口Igenerics
T GetById(int Id)
实际上我需要< br $>
T GetById(int Id,key2,key3,...等)
我尝试过:
如何使用多个参数
< pre> T GetById(int Id,key2,key3,... etc)
以及如何在控制器上调用它
解决方案
在方法签名中使用params关键字传递可变数量的参数。
params keyword - C#Reference | Microsoft Docs [ ^ ]
problem
How to use dynamic datatype on more than one key GetByID repository pattern ?
public T GetById(int Id) { return dbSet.Find(Id); } and in interface Igenerics T GetById(int Id)
actually i need
T GetById(int Id,key2,key3,...etc)
What I have tried:
How to use more than one parameters
<pre>T GetById(int Id,key2,key3,...etc)
and how to call it on controller
解决方案
Use the "params" keyword in your method signature to pass a variable number of parameters.
params keyword - C# Reference | Microsoft Docs[^]
这篇关于如何在多个密钥getbyid存储库模式上使用动态数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文