我目前正在尝试将订单添加到LINQ查询中,该查询将按EF对象中的datetime字段排序:
return this.SortingDirection.Equals("asc", StringComparison.InvariantCultureIgnoreCase) ? entities.OrderBy(e => e.ProcessStartTime) : entities.OrderByDescending(e => e.ProcessStartTime);
Run Code Online (Sandbox Code Playgroud)
当SortingDirection设置为desc它工作正常.但是当asc我设置为没有记录!
在查看SQL Server Profiler时,事实证明DateTime对象的格式不同!
用于DESC:
ORDER BY [Project1].[StartTime] DESC',N'...@p__linq__22='2015-01-07 09:00:23',@p__linq__23='2015-01-07 09:00:23',@p__linq__24='2015-01-07 09:05:30',@p__linq__25='2015-01-07 09:05:30'
Run Code Online (Sandbox Code Playgroud)
并为ASC:
ORDER BY [Project1].[StartTime] ASC',N'...@p__linq__22='2015-07-01 09:00:23',@p__linq__23='2015-07-01 09:00:23',@p__linq__24='2015-07-01 09:05:30',@p__linq__25='2015-07-01 09:05:30'
Run Code Online (Sandbox Code Playgroud)
已交换天数和月份,导致sql查询无法返回结果.
这对我来说这个IQueryable.OrderBy()方法没有使用正确的本地格式/不同格式OrderByDescending(),这可能是EF中的一个错误吗?
我可以添加哪些连接字符串来强制执行此操作或我可以按这些日期排序的其他方式?
我的设置:
非常感谢
我们最近开始迁移到Castle Windsor,我在运行WCF服务时遇到了一些问题.它是IIS中的常规Windows服务,我们提供SSL材料并使用自定义X509CertificateValidator来验证客户端提供的证书.
下面是我用来创建WCF服务的代码.它位于引用它的WCF服务的单独项目中.
public IWindsorContainer RegisterService<T,K>(
IServiceBehavior customBehavior,
Action<ServiceHost> onCreate = null,
Action<ServiceHost> onOpen = null,
Action<ServiceHost> onClose = null,
Action<ServiceHost> onFault = null) where T : class where K : T
{
var facility = this.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero);
var serviceModel = new DefaultServiceModel()
.OnCreated(onCreate)
.OnOpened(onOpen)
.OnClosed(onClose)
.OnFaulted(onFault);
var service = Component.For<T>()
.ImplementedBy<K>()
.AsWcfService<T>(serviceModel)
.LifestylePerWcfOperation<T>();
if (customBehavior != null)
facility.Register(Component.For<IServiceBehavior>().Instance(customBehavior));
facility.Register(service);
return facility;
}
Run Code Online (Sandbox Code Playgroud)
该服务按预期启动(我可以使用chrome导航到该服务而没有任何问题),并且该服务正在呈现并验证SSL材料(即命中自定义验证器)但在此之后,客户端获取此信息FaultException:
Looks like you forgot to register the …Run Code Online (Sandbox Code Playgroud)