FSou1
FSou1

Reputation: 1941

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();

Upvotes: 0

Views: 510

Answers (1)

nathan gonzalez
nathan gonzalez

Reputation: 11987

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>;
}

Upvotes: 2

Related Questions