存储过程:
ALTER PROCEDURE [dbo].[P_GetProByCity]
@City NVARCHAR(50)
AS
SELECT top 1 Province FROM Mobile WHERE City like '%'+@City+'%' C#代码:
public ObjectResult<global::System.String> GetProByCity( global::System.String city)
{
ObjectParameter cityParameter;
if (city != null)
{
cityParameter = new ObjectParameter("City", city);
}
else
{
cityParameter = new ObjectParameter("City", typeof(global::System.String));
} ObjectResult < global::System.String > result= base.ExecuteFunction<global::System.String>("GetProByCity", cityParameter);
return result;
} 怎么拿 ObjectResult < global::System.String > 里面的值呢?
ALTER PROCEDURE [dbo].[P_GetProByCity]
@City NVARCHAR(50)
AS
SELECT top 1 Province FROM Mobile WHERE City like '%'+@City+'%' C#代码:
public ObjectResult<global::System.String> GetProByCity( global::System.String city)
{
ObjectParameter cityParameter;
if (city != null)
{
cityParameter = new ObjectParameter("City", city);
}
else
{
cityParameter = new ObjectParameter("City", typeof(global::System.String));
} ObjectResult < global::System.String > result= base.ExecuteFunction<global::System.String>("GetProByCity", cityParameter);
return result;
} 怎么拿 ObjectResult < global::System.String > 里面的值呢?
foreach (string temp in result)
{
province = temp;
}
return province;只能这样拿里面的值. 还有其他方法么?
@Province NVARCHAR(50) OUTPUT,
@City NVARCHAR(50)
AS
SELECT @Province= Province FROM Mobile WHERE City like '%'+@City+'%'
如果是这样的你该怎么写C#方法?