我在我的实体数据模型中有一个存储过程,并将其添加到函数导入中.
问题是......当且仅当我将返回指定为实体类型时,Visual Studio才会在模型的代码隐藏中生成函数代码. 标量和null返回类型不起作用.选择它们时,Visual Studio不会生成功能代码.
有什么我想念的,或者这是一个错误?
任何解决方法?
DateTime是否在SQL Server评估的EF查询中运行,因为运行IL的机器会评估查询表达式之外的DateTime函数?
我有一个具有SalesOrders的应用程序
public class SalesOrder
{
public Int32 OrderID {get;set;}
public DateTime Expiration {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
我运行EF查询并在执行此操作时获得不同的结果:
DateTime utcnow = DateTime.UtcNow;
var open = (from a in context.SalesOrders
where a.Expiration > utcnow
select a).ToList();
Run Code Online (Sandbox Code Playgroud)
比我这样做:
var open = (from a in context.SalesOrders
where a.Expiration > DateTime.UtcNow
select a).ToList();
Run Code Online (Sandbox Code Playgroud)
我认为这是因为实体框架查询中的DateTime.UtcNow由SQL Server评估,而DateTime.UtcNow在查询之外由运行IL的机器评估; 我基于这个答案.
我在Azure平台中作为服务,如果重要的话,使用Azure SQL DB在本地进行调试.
我使用此代码获取Server Date但我真的不明白.CreateDateTime()不是sql函数.所以它是什么?
DateTime ServerDate = Entities.CreateQuery<DateTime>("CurrentDateTime()").AsEnumerable().First();
Run Code Online (Sandbox Code Playgroud)
我认为CreateQuery函数中的字符串必须是一个SQL查询.这是错的吗?
我打开了SSMS并写了CurrentDateTime()并且我得到了一个错误,我也测试了这个:SELECT CurrentDateTime(),我得到一个错误agian,CurrentDateTime()不是一个sql函数