我想从我的表中返回前1 CustomerId
,如下所示:
string nxtCustId = db.ExecuteStoreQuery<string>("SELECT TOP 1 CustId FROM CustomerMaster WHERE Id >=(SELECT Max(Id) FROM CustomerDetail ) ORDER BY Id ").ToString();
但它返回System.Data.Objects.ObjectResult1[System.String]
我想只使用ExecuteStoreQuery
或ExecuteStoreCommand
。
答案 0 :(得分:0)
string nxtCustId = db.ExecuteStoreQuery<string>(
"SELECT TOP 1 CustId FROM CustomerMaster WHERE Id >=(SELECT Max(Id) FROM CustomerDetail ) ORDER BY Id ")
.FirstOrDefault();
话虽如此,不要以这种方式创建“ID”;这不是多用户安全的。使用自动增量字段或生成器/序列。