开发者

ExecuteSprocAccessor how to return string from stored procedure?

开发者 https://www.devze.com 2023-01-15 11:36 出处:网络
I am using Enterprise Library 5, set up the Database successfully 开发者_JAVA技巧but am now facing the following problem.

I am using Enterprise Library 5, set up the Database successfully 开发者_JAVA技巧but am now facing the following problem.

I have a stored procedure which is a simple select statement which returns 1 string (not an output parameter).

In code I wrote:

var result = _db.ExecuteSprocAccessor<string>("GetTypeOfPerson", mapper, parameters);

However this won't work as string does not have a parameterless constructor. Any way around? Or how can I call with Enterprise Library the stored procedure and obtain my result?


that indeed won't work out. Do the following instead:

var result = _db.ExecuteScalar("GetTypeOfPerson", parameters);

That'll give you exactly one result back.

0

精彩评论

暂无评论...
验证码 换一张
取 消