我有一個包含多列的表格,我需要更新與一組參數匹配的列。是否可以連接字符串,然後使用字符串結果來使用Telerik的OpenAccess更新數據庫的匹配命名列?如果是這樣,我認爲這裏需要思考?我希望能夠做一些事情如下所示:通過將列名稱與字符串匹配來更新表格列
一個簡單的例子表:
Sku QtyOnHand Whse1Aug2017 Whse2Aug2017 Whse3Aug2017
==================================================================
ABC-123 87 2 4 8
XYZ-789 43 0 5 4
string warehouseId = "1"
string month = "Aug"
string year = "2017"
string sku = "ABC-123"
int qtySold = 3;
string columnName = "Whse" + warehouseId + month + year;
var query = (from s in model.Sales
where s.SKU == sku
select s).FirstOrDefault();
query.columnName = query.columnName + qtySold;
query.SaveChanges();