sql语句:INSERT INTO `vol`.`test_number`(`ProductCode`, `ProductName`, `NumberQty`) VALUES ('tt', 'ss', 199);用SqlSugar写这个SQL语句
时间: 2023-04-10 08:01:06 浏览: 147
Sure, here's how you can write this SQL statement using SqlSugar:
var db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "your_connection_string_here",
DbType = DbType.MySql, // or DbType.SqlServer, DbType.Oracle, etc.
IsAutoCloseConnection = true
});
var testNumber = new TestNumber()
{
ProductCode = "tt",
ProductName = "ss",
NumberQty = 199
};
db.Insertable(testNumber).ExecuteCommand();
Note: You need to replace "your_connection_string_here" with your actual database connection string, and define the TestNumber class with the same properties as the test_number table.
相关问题
sql语句:INSERT INTO `vol`.`test_number`(`ProductCode`, `ProductName`, `NumberQty`) VALUES ('tt', 'ss', 199);用ef写这个SQL语句
可以使用以下代码:
```
using (var context = new YourDbContext())
{
var testNumber = new TestNumber
{
ProductCode = "tt",
ProductName = "ss",
NumberQty = 199
};
context.TestNumbers.Add(testNumber);
context.SaveChanges();
}
```
其中,YourDbContext 是你的 DbContext 类型,TestNumber 是对应的实体类。
sql语句:UPDATE `vol`.`test_number` SET `ProductCode` = '33', `ProductName` = '1', `NumberQty` = 0 WHERE `id` = 3; 用SqlSugar写这个SQL语句
可以使用以下代码:
var db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "your connection string",
DbType = DbType.MySql,
IsAutoCloseConnection = true
});
db.Updateable<TestNumber>()
.SetColumns(t => new TestNumber()
{
ProductCode = "33",
ProductName = "1",
NumberQty = 0
})
.Where(t => t.Id == 3)
.ExecuteCommand();
阅读全文