public class Order
{
[Key]
public int ID { get; set; }
public string Code { get; set; }
public string Type { get; set; }
}
context.Set<Order>().Where(p => p.ID== 2 || p.Type == "def")
.Update(g => new Order() { Code = "code" + DateTime.Now.ToShortDateString() });
相同的代码,在 Mysql 中,innerJoinSql 将是
SELECT
`Extent1`.`ID`
FROM `Order` AS `Extent1`
WHERE (2 = `Extent1`.`ID`) OR (@gp1 = `Extent1`.`Type `)
在 MSSQL 中它将是
SELECT
[Extent1].[ID] AS [ID]
FROM [dbo].[Order] AS [Extent1]
WHERE [Extent1].[ID] = 2 OR [Extent1].[Type ] = N'def'
innerJoinSql 值来自 EntityFrame.ObjectQuery.ToTraceString() 方法。
string innerJoinSql = ObjectQuery.ToTraceString();
为什么使用 PRIMARY KEY 是正确的,而其他字段会在 MySql 中生成一个@gp1
我已经使用 MyMySqlBatchRunner
public class DbContextConfiguration : DbConfiguration
{
public DbContextConfiguration()
{
EntityFramework.Locator.Current.Register<EntityFramework.Batch.IBatchRunner>(
() => new EntityFramework.Batch.MySqlBatchRunner());
}
}