简体   繁体   中英

LINQ stored procedure and return value

I have SQL query (stored procedure) and generated method in dataContext.

In my stored procedure, I select 4 rows, but in ReturnValue I have "0".

(4 row(s) returned)
@RETURN_VALUE = 0

Can I return rows? :(

In repository:

public IEnumerable<Index_RandomTale> GetRandomTalesForIndex()
{
    return _dataContext.Index_GetRandomTales().ReturnValue as IEnumerable<Index_RandomTale>;
}

In my controller:

IEnumerable<Index_RandomTale> tales = _dataManager.commonRepository.GetRandomTalesForIndex();

i could be wrong here, but you don't actually want the return value, you just want the function call, so it should be this:

public IEnumerable<Index_RandomTale> GetRandomTalesForIndex()
{
    return _dataContext.Index_GetRandomTales() as IEnumerable<Index_RandomTale>;
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM