有没有办法重新编译或至少"检查编译"存储过程?有时我们会进行架构更改 - 添加或删除列等.并尽最大努力识别受影响的触发器,但只会被我们错过的触发器咬住,这会在下一次运行时发挥作用.SQLServer 2k5或2k8.
I have an interesting need for an extension method on the IEumerable interface - the same thing as List.ConvertAll. This has been covered before here and I found one solution here. What I don't like about that solution is he builds a List to hold the converted objects and then returns it. I suspect LINQ wasn't available when he wrote his article, so my implementation is this:
public static class IEnumerableExtension
{
public static IEnumerable<TOutput> ConvertAll<T, TOutput>(this IEnumerable<T> collection, …Run Code Online (Sandbox Code Playgroud) 我有一个IRepository <T>接口,有许多T和几个实现(按需DB,Web服务等).我使用AutoFac为许多T注册IRepository,具体取决于我想要的每个T的存储库类型.
我还有一个基于.NET缓存的实现,它在缓存中查找T,然后调用"真正的"IRepository.Find来解决缓存未命中问题.它构造如下:
new CachingRepository(realRepository, cacheImplementation);
Run Code Online (Sandbox Code Playgroud)
我想使用配置标志来决定AutoFac是否提供基于缓存的IRepository或"真实的东西".似乎'realRepository'来自要求AutoFac解析IRepository <T>但是当客户要求解析同一个接口时会得到什么?如果设置了标志,我希望它们获取CachingRepository.
我无法理解如何实现这种基于标志的解决方案.有任何想法吗?
更多的警告而不是问题:
我们今天早上解决了一个非常令人费解的错误.我们有各种报告,允许用户输入他们想要运行的日期范围.假设是,如果您要求从2010年8月1日到2010年8月10日的报告,您打算包括 8/10/2010,那么报告的结束日期不是8/10,那是之后的事情.
它不能是8/11/2010,因为这些报告中的一些汇总了一天中发生的所有事情,在那一天将它们分组到午夜,因此每日汇总将包括额外的一天 - 而不是我们想要的.
为了避免错过任何非常接近当天结束的项目的可能性,我们将结束日期计算为比明天更少的"一个标记":
public static DateTime EndOfDay(DateTime day)
{
return day.Date.AddDays(1).AddTicks(-1);
}
Run Code Online (Sandbox Code Playgroud)
在内部,这最终会像8/10/2010 12:59:59.9999PM
好吧,当你将这个DateTime传递给SQL Server中的DATETIME参数时,它会将值UP舍入到8/11/2010 00:00:00!因为我们的查询使用
DateField BETWEEN @FromDate AND @ToDate
Run Code Online (Sandbox Code Playgroud)
代替
DateField >= @FromDate AND DateField < @ToDate
Run Code Online (Sandbox Code Playgroud)
我们看到2010年8月1日至2010年8月10日的报告中包含了2010年11月8日的报告.
我们发现真正问题的唯一方法是通过字符串往返日期.DateTime.ToString()也是如此,所以我们最终得到了SQL Server很满意的8/1/2010 12:59:59 PM.
所以现在我们的'结束日'方法看起来像这样:
public static DateTime EndOfDay(DateTime day)
{
// Cant' subtract anything smaller (like a tick) because SQL Server rounds UP! Nice, eh?
return day.Date.AddDays(1).AddSeconds(-1);
}
Run Code Online (Sandbox Code Playgroud)
抱歉不是问题 - 只是觉得有人可能觉得它很有用.
我想知道一种简单的方法来按添加日期对列进行排序,例如:
ID|Name|Age|Date
1 John 21 20/03/2012
2 Chart 22 21/03/2012
3 Dart 31 22/03/2012
4 Rat 12 23/03/2012
Run Code Online (Sandbox Code Playgroud)
所以如果你知道我的意思,我想添加一个选项来对列的Date日期值进行排序.
谢谢