如何将动态类型的IEnumerable转换为int或string?这是我的代码,我无法弄清楚如何从SQL查询中获取int
public class SaveCustomerData : IDisposable
{
private readonly string _connectionString;
private readonly Database _db;
public SaveCustomerData(string connectionString)
{
_connectionString = connectionString;
_db = Database.Open(connectionString);
}
public void Insert(string fname, string lname, string phone, string cellno, DateTime dob, string gender, string address, string address2, string creditno, string city, string postalcode, string email) {
**int uid = _db.Query("SELECT UserID FROM UserProfile WHERE Email=@0",email);**
_db.Execute("INSERT INTO Customer_Table (customer_fname, customer_lname, customer_phone, customer_mobile, customer_dob, customer_gender, customer_address, customer_address2, customer_creditno, cutomer_city, cutomer_postal, customer_email) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12",
fname, lname, phone, cellno, dob, gender, address, address2, creditno, city, postalcode, uid);
}
答案 0 :(得分:0)
使用db.QueryValue
代替查询
int key = (int)_db.QueryValue("SELECT UserID FROM UserProfile WHERE Email=@0",email);