如何从DataLayer返回值列表。 [英] How to return a list of value from DataLayer.
本文介绍了如何从DataLayer返回值列表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的业务层,此代码只返回一个值,
如何从DataLayer返回值列表。
This is my Business layer ,this code returns only a single value,
How to return a list of value from DataLayer.
public class GetLocal
{
public BusinessObj.Tables.GetLocal GetItem(int TransId)
{
DataLayer.PL.GetLocal objGetLocalDL = new DataLayer.PL.GetLocal();
try
{
return objGetLocalDL.GetItem(TransId);
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex.InnerException);
}
}
}
推荐答案
你会改变
You would change
public BusinessObj.Tables.GetLocal GetItem(int TransId)
to
to
public List<businessobj.tables.getlocal> GetItem(int TransId)
</businessobj.tables.getlocal>
然后在您的代码中,您需要实例化一个新的List<>您的对象,向其添加项目,然后将其返回。
and then in your code you need to instantiate a new List<> of your object, add items to it, and then return it.
这篇关于如何从DataLayer返回值列表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文