You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ExecuteScalarDictionary method executes the query, and returns the dictionary. The keys are loaded from a column specified by the keyField parameter and values are loaded from a column specified by the valueField. Other columns are ignored.
ExecuteScalarDictionary.cs
usingSystem;usingSystem.Collections.Generic;usingNUnit.Framework;usingBLToolkit.Data;namespaceHowTo.Data{usingDataAccess;[TestFixture]publicclassExecuteScalarDictionary{Dictionary<int,string>GetNameDictionary(){using(DbManagerdb=newDbManager()){returndb.SetCommand("SELECT * FROM Person").ExecuteScalarDictionary<int,string>("PersonID","FirstName");}}[Test]publicvoidTest(){Dictionary<int,string>dic=GetNameDictionary();Assert.AreNotEqual(0,dic.Count);Assert.IsNotNull(dic[1]);}}}