Multiple/single instance of Linq to SQL DataContext

Rick Strahl has a nice article about your options: http://www.west-wind.com/weblog/posts/246222.aspx. See also: LINQ to SQL – where does your DataContext live?. You may want a slightly different strategy for each type of deployment – web, desktop, windows service… Summarized, your options are: Global DataContext – dangerous in multi-threaded environments (including web apps). Remember that instance … Read more

linq to entities vs linq to objects – are they the same?

That is definitely not the case. LINQ-to-Objects is a set of extension methods on IEnumerable<T> that allow you to perform in-memory query operations on arbitrary sequences of objects. The methods accept simple delegates when necessary. LINQ-to-Entities is a LINQ provider that has a set of extension methods on IQueryable<T>. The methods build up an expression … Read more

.net Core Quartz Dependency Injection

You can use the Quartz.Spi.IJobFactory interface and implement it. The Quartz documentations states: When a trigger fires, the Job it is associated to is instantiated via the JobFactory configured on the Scheduler. The default JobFactory simply activates a new instance of the job class. You may want to create your own implementation of JobFactory to … Read more

C# Regex.Split: Removing empty results

Regex lineSplitter = new Regex(@”[\s*\*]*\|[\s*\*]*”); var columns = lineSplitter.Split(data).Where(s => s != String.Empty); or you could simply do: string[] columns = data.Split(new char[] {‘|’}, StringSplitOptions.RemoveEmptyEntries); foreach (string c in columns) this.textBox1.Text += “[” + c.Trim(‘ ‘, ‘*’) + “] ” + “\r\n”; And no, there is no option to remove empty entries for RegEx.Split as … Read more

.NET: Get all Outlook calendar items

I’ve studied the docs and this is my result: I’ve put a time limit of one month hard-coded, but this is just an example. public void GetAllCalendarItems() { Microsoft.Office.Interop.Outlook.Application oApp = null; Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null; Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null; Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null; oApp = new Microsoft.Office.Interop.Outlook.Application(); mapiNamespace = oApp.GetNamespace(“MAPI”); ; CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); … Read more

WPF – Remove focus when clicking outside of a textbox

Rather than adding new control to window, I think you should give your Grid a name and react to the MouseDown event on your window, moving the focus to the Grid itself. Something like this: <Window x:Class=”WpfApplication1.Window1″ xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”Window1″ Height=”412″ Width=”569″ MouseDown=”Window_MouseDown” Name=”window1″> <Grid ShowGridLines=”False” Background=”#01FFFFFF” KeyDown=”Grid_KeyDown” Name=”grid1″ Focusable=”True”> <TextBox Width=”120″ Margin=”117,61,0,0″ Name=”textBox1″ VerticalAlignment=”Top” … Read more

tech