本文整理汇总了C#中System.Data.SqlClient.SqlConnection.GetAll方法的典型用法代码示例。如果您正苦于以下问题:C# SqlConnection.GetAll方法的具体用法?C# SqlConnection.GetAll怎么用?C# SqlConnection.GetAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlConnection
的用法示例。
在下文中一共展示了SqlConnection.GetAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public HttpResponseMessage Get()
{
var connectionString = ConfigurationManager.ConnectionStrings["CraftingTable"].ConnectionString;
IDbConnection sqlConnection = new SqlConnection(connectionString);
//var appUsers1 = sqlConnection.Query<AppUser>("Select * from AppUsers").ToArray<AppUser>();
var appUsers = sqlConnection.GetAll<AppUser>().ToArray<AppUser>();
sqlConnection.Close();
return Request.CreateResponse(
HttpStatusCode.OK,
new AppUsersModel {AppUsers = appUsers});
}
示例2: Dapper
private static void Dapper(int eachCount)
{
GC.Collect();//回收资源
System.Threading.Thread.Sleep(2000);//休息2秒
//正试比拼
PerHelper.Execute(eachCount, "Dapper", () =>
{
using (SqlConnection conn = new SqlConnection(PubConst.connectionString))
{
var list = conn.GetAll<Test>();
}
});
}
示例3: GetMethods
public static void GetMethods()
{
using (var cn = new SqlConnection(CONNECTION_STRING))
{
var contact = cn.Get<Contact>(1);
var contacts = cn.GetAll<Contact>();
Console.WriteLine(
"Found contact {0} {1} and {2} total contacts",
contact.FirstName,
contact.LastName,
contacts.Count());
}
Console.ReadKey();
}