1
我是新來的C#和我有困難的時候搞清楚了這一點,在C#編寫服務器存儲過程
public UserNotificationFeed GetNotificationFeed(TenantInfo tenant, List<int> notificationId)
{
UserNotificationFeed userNotificationFeed = new UserNotificationFeed();
string sql = "select " + NotificationFieldList + " from UserNotificationFeed where MsgId = @MsgId";
Database databaseObj = SocialDB.GetDataBase(tenant.ConnectionString, tenant.ProviderName);
DbCommand commandObj = databaseObj.GetSqlStringCommand(sql);
databaseObj.AddInParameter(commandObj, "MsgId", DbType.Int64, notificationId);
using (IDataReader reader = databaseObj.ExecuteReader(commandObj))
{
while (reader.Read())
{
userNotificationFeed = new UserNotificationFeed();
this.PopulateObject(userNotificationFeed, reader);
}
}
return userNotificationFeed;
}
我想的是,
string sql = "select " + NotificationFieldList + " from UserNotificationFeed where MsgId = @MsgId";
採取MsgId
列表s傳遞了一個List<int> notificationId
。
任何幫助真的很感激。
這不是一個「存儲過程」,順便說一句 - 它只是一個命令。不重要的一點 - 只是一些術語。 –
你是否收到異常?是不是運行 –
隨機問題:如果有多個id,你的代碼目前只返回**最後一行**。你打算在這種情況下做什麼? –