Tag | LINQ Posts

As you might have seen, there has been some blogging about named format strings in the last days. Fun With Named Formats, String Parsing, and Edge Cases (Phil Haack) Named Formats Redux (Phil Haack) Named Format Strings(James.ToString()) If you didn't came across it, the general idea is to use something like: "foo '{foo}' bar: {bar}".Format(new {foo = "abc", bar= 123}) Since I already had an analog solution for this problem I thought it would be fun to run it in 'competition' with the other implementations. ...
Programming Visual Basic applications? Typemock have released a new version of their unit testing tool, Typemock Isolator 5.2. This version includes a new friendly VB.NET API which makes Isolator the best Isolation tool for unit testing A Visual Basic (VB) .NET application. Isolator now allows unit testing in VB or C# for many ‘hard to test’ technologies such as SharePoint, ASP.NET MVC, partial support for Silverlight, WPF, LINQ, WF, Entity Framework, WCF unit testing and more. Note that the first ...
Programming Visual Basic applications? Typemock have released a new version of their unit testing tool, Typemock Isolator 5.2. This version includes a new friendly VB.NET API which makes Isolator the best Isolation tool for unit testing A Visual Basic (VB) .NET application. Isolator now allows unit testing in VB or C# for many ‘hard to test’ technologies such as SharePoint, ASP.NET MVC, partial support for Silverlight, WPF, LINQ, WF, Entity Framework, WCF unit testing and more. Note that the first ...
The list of new INETA speakers has finally been announced on David Walker's blog. I've included the list with links below as well though. Let's get those speaker requests in and start putting these guys to work! 1. Chris Williams 2. Keith Elder 3. Jason Bock 4. Claudio Lassala 5. Rachel Appel 6. Andrew Dunn 7. Chris Love 8. Cory Smith 9. Tim Rayburn 10. Jim Wooley 11. Rob Windsor 12. Amanda Laucher 13. Adam Machanic 14. Stuart Celarier 15. Pete Brown 16. Steve Andrews D ...
I’m working on a project that runs on a smart phone using the compact framework. The user needs to be able to enter the name of a colour (e.g. “Green”) and the app needs to be able to display an icon in that colour. My first thought was to use the FromKnownColor() static method on the Color class, but it turns out that’s not implemented in the compact framework. Given that the colour class has static properties for all the well known colours, all with the correct names, I felt there must be some ...
My Considerations Until now I used some custom orm tool (written by me), it was working with stored procedures, because my idea is that the best optimization you may accomplish in sql code. But now as the project increased and its fonctionality has blow up, I realise that in the future must be used some more adapted orm for supporting Domain Model and Data Mapper, with wich can be used in a more simple fashion the concepts of Unit of Work, Repositories etc. I indeed fell the necessity to pass to ...
In this issue: David Betz, Shawn Wildermuth, and Terence Tsang From SilverlightCream.com: Setting a Silverlight 2 Startup Breakpoint using WinDBG David Betz continues discussing debugging Silverlight using WinDBG. It looks like direct questions might get answered, so if you have 'em, post 'em! See my Silverlight Data Access Talk from DevReach If you weren't at DevReach in Bulgaria, Shawn Wildermuth has a link to the video of his Silverlight Data Access talk. This is LINQ, ASMX, WCF, REST, Astoria, ...
The next versions of C# and VB will have improved parity between them. From the consultant perspective, this is important because one can't always choose which language to use. Although a seasoned C# developer can program in VB as well, it seems that gotchas appear and you have to refer to the documentation to figure out how do something that you wouldn't even need to think about in your primary language. The goal of the Visual Studio Managed Languages team is to maintain the character of each language ...
I've started to use LINQ and feel that query expression are very powerfull. Unfortunately , when in debugger I've tried to Edit and continue, it gave me an error Modifying a 'method' which contains a query expression will prevent the debug session from continuing while Edit and Continue is enabled. The post Orcas - Edit and continued not working when linq used - MSDN Forums explains that "it is a limitation of the environment in which Edit and Continue operates". I've submitted suggession to MS - ...
ORM made easy with Linq to SQL and Extension Methods Download Sample Code Few things get developers as passionate, angry, or roused as ORM (Object Relational Mapping) strategies, short of dissing Mountain Dew. This is probably because there are so many ways to do it and doing it wrong can result in big, big headaches. Nevertheless, this is an area that is really pretty straight forward. I’ve got some stuff over here that is shaped one way and some stuff over there that looks (maybe very) different, ...
In ParaPlan 4.0, we use twitter to maintain a change log. I wanted to display this information to our users, so I wrote a little class that calls the RSS feed and uses LINQ to parse the data. All I need is the message and the date, so that is all it pulls out. Here is the class: public class Twitter { public string Message { get; set; } public DateTime PubDate { get; set; } public static List<Twitter> Parse(string User) { var rv = new List<Twitter>(); var url = "http://twitter.com/statuse... ...
1. Introduction This is a follow-up to the "An attribute based approach to business object validation" article in which i introduced the use attributes and reflection to validate business objects. I also promised to write another article on data converters and method based validators, and here it is. 2. Background In this article i will use an example to show how you can validate your business object using a method based attribute and how you can convert data assigned to properties when it is saved ...
Article Source: http://geekswithblogs.net/m... I've recently been looking at a proof of concept of implementing the resequencer pattern in BizTalk 2009. When I've implemented this pattern in the past it usually required a lot of custom development to create a database to support the resequencing process. If you would like to see more on the theory of the resequencer pattern then refer to the following link: http://www.eaipatterns.com/... I've seen a few .net and BizTalk ...
Welcome to my first ever blog! So, of course, I had to start with the obligatory "hello world."

I hope to use this space to talk about the latest C# and .NET developments that interest me most. You know, things like LINQ and WPF and C#, etc...
So I had hoped my first blog post would be along the lines of .NET development but it looks like it was Delta that motivated me first. Stand by for some fun with LINQ to SQL coming soon! Dear Delta Customer Care, I remember being about 8 years old the first time I flew Delta. To this day I remember being taken to the cockpit and being awed by the array of buttons, gauges and instruments. In fact, I still have a toy Delta aircraft and a pair of wings from that trip, although they are buried deep in ...
It's official! The Frederick .NET User Group (FredNUG) is now a member of INETA. At the December FredNUG meeting, Frank La Vigne, the INETA Membership Mentor for Maryland, DC, and Delaware, was in attendance to make the official announcement to the group. It's great to be recognized by INETA and to have its support. Since FredNUG's founding in September 2008, we've already enjoyed hearing from a few notable speakers, including G. Andrew Duthie and Pete Brown. Of course, we're always looking for more ...
Ever need to convert a List of strings in a comma delimited list? In the past I'd write a foreach loop. Something like: public static string FlattenStringList(List<s... items) { StringBuilder str = new StringBuilder(); bool firstOne = false; foreach (string item in items) { if (!firstOne) str.Append(","); else firstOne = false; str.Append(item); } return str.ToString(); } Now, thanks to String.Join and Linq, I can compress it to a single expression: string.Join(",", items.ToArray()); Also ...
There are a lot of situations in Silverlight and WPF where you would like to get a list of items from a collection of a certain type. For example all textboxes in a Grid, or all customer records from a ListView. LINQ provides us with an extension method to do this very easily, the OfType<T>() extension on IEnumerable: public static IEnumerable<TResult> OfType<TResult>( this IEnumerable source ) Let me explain the use of this method thru some examples. Say you have a grid with some ...
I started this blog back in September with a particular purpose in mind. Every yahoo and his brother has a blog these days, and by far the majority of them are absolute trash, but every so often there's a gem. As developers, we seem to mostly agree on which ones are the gems. Non-developers most likely have different lists, depending on their focus. There's a long list of blogs I love to read, and couldn't possibly hope to be counted among them, but one day I realized something. There's a lot of ...
The work I did on benchmarking DataTable performance (or lack thereof *cough cough*) has been published in an article on the MSDN VB Dev Center. For those of you wondering about the results I mentioned a few months ago, they're included there. I've also included some work on benchmarking LINQ select queries and aggregation in comparison to the DataTable equivalents. Many thanks to Beth Massi for helping get this published ...
Below is the method to output Generic list of objects as string. UPDATE: I've replaced my original function with the code suggested by James Curran (see his comment below). public static string ToString<T>(IEnumerab... messages, string sComment) { StringBuilder sRet = new StringBuilder(sComment); if (messages != null) { foreach (T msg in messages) { sRet.AppendLine(msg.ToStrin... } } return sRet.ToString(); } /// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> ...
How can you use the word efficient memory usage and mention in the same headline .NET? We all know that C++ is much more efficient with regards to memory consumption. Yes I agree that if you really love your memory you should think twice if .NET is the right choice for you. There have been reasons why Windows Vista has not a single managed executable executed while starting up. Ok the Event Viewer is managed which explains why it is starting so slow. First of all you need to know what things cost. ...
QCon is an amazing conference. Maybe 300+ attendees and about 100+ speakers. It is targeted at enterprise developers, and is not for the 'next, next, finish' developer. There feels a definite lack of .Net here at the conference (I mean other than the specific .Net track) but there is a good Java, Python, Ruby, etc. feel which makes me not feel too out of the loop. If you have not heard of QCon before, I encourage you too look at it as a possible conference to attend next year. I have had the pleasure ...
This code example will show how to hide a listbox from the user when it doesn’t have any items. It involves binding the Visibility of the listbox to the Items.Count of the listbox. We run the Items.Count through a converter that will return a Visibility.Visible object if the Item.Count is not zero. Here is the converter class: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; using System.Windows; namespace HideAListBox { public class ...
Kansas City hosted a Kansas City Day of .NET this past Saturday; I was fortunate enough to be given the opportunity by Lee Brandt to present there. Wonderful time was had for all, food & drinks were provided along with some nice raffled items at the end. Kudos to the 3 facilitators of this event: Lee Brandt, Becky Isserman and Doug Butscher. In any case, I was there presenting Parallel Programming for Managed Code Developers; essentially re-delivering Daniel Moth's excellent PDC presentation. ...
Want to know what Services or/and Processes are running currently on your PC? In one of my previous project I implemented small diagnostic utility which showed what processes and services are running on host box. Here is the example how to obtain this information. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Management; namespace ManagementInstrumentation { class Program { static void Main(string[] args) { ListServices(); Console.ReadLine(); ListProcesses(); ...
Just posted about reading XML via LINQ. Now, this post is about the opposite direction - emitting XML from a collection. The simplicity of LINQ provides a straightforward interaction with XML makes LINQ to XML for me one of the easiest and most natural ways to interact with XML. The following emits a collection of objects out to an XElement (which can be streamed elsewhere as required. 35 Customer[] customers = new Customer[]{ 36 new Customer{ 37 firstName="john", lastName="lennon"}, 38 new Customer{ ...
Tampa Code Camp is this weekend and I’m presenting 3 sessions: Understanding Lambda Expressions Lambda expressions are an integral part of LINQ and a powerful new feature of .NET 3.0. We will explore the history of lambda expressions and how they operate in .NET, and how they can dramatically simplify your code.Lambda expressions are an integral part of LINQ and a powerful new feature of .NET 3.0. Memory Management Fundamentals – Garbage Collection Deep Dive Memory management in .NET is one of the ...
I was working on a small web application that was built very quickly using Linq to SQL and I wanted to ensure that a particular page wasn't loading more data than needed into memory. This particular page had a simple GridView, and in the one and only item template, there was an ASP.Net Image (along with some other stuff). The data source was of type IQueryable<Article> and an Article may have zero to many ArticleImages. A relationship was present in the dbml, so the ArticleImages were generated ...
My buddy Juan Larios did a 4 part blog series on using a…well, you read the title of this post so you know. I figured the Sharepoint-inclined readers of my blog might find it interesting, so below are the links. Part 1 Part 2 Part 3 Part 4 Enjoy! D ...
I present at a lot of the local Florida code camps (and some out of state ones as well) and have a presentation that focuses on understanding Lambda expressions in .NET. This is not an exhaustive list, but it is a subset of the books, articles, blogs, and presentations that I used to form the content of my presentation. Books Essential C# 3.0: For .NET Framework 3.5 (2nd Edition) (Microsoft .Net Development Series) (Paperback) (Mark Michaelis) The C# Programming Language (3rd Edition) (Microsoft ...
There are ways LINQ can query completely dynamically from Database. I had requirement to get a column value of a table in a generic and dynamic manner for a given key value. Here I pass the table type (LINQ type) and key value to retrieve other column values of the table in a totally dynamic manner. private string GetColumnValue(DataContext dc, Type tableType, Type keyColumnType, string keyColumnName, object objectValue, string getColumnName) { string getColumnValue = null; IQueryable queryableData ...
One of the many new features Microsoft is planning to bring to .NET 4.0 is Code Contracts. In a nutshell, this is a feature that allow a developer to formally specify the requirements of a function, and the state of the system when the function completes (e.g. A parameter will be non-null, or a property of the object will be greater than 0 at the end of the function). The initial work for this came from the Spec# project, a Microsoft Research project that extended the C# language to include keywords ...
Recently I had to deal with some XML supplied to a development group that wasn't the greatest in structure. For one, there was inconsistent use of namespaces and each repeating element had the namespace duplicated. The goal was to retrieve from the XML various element values for a business object. So, using LINQ to XML, there's some pretty neat ways to go about this. The most succinct that I came up with is below - of course it could be tiny bit more succinct in terms of not using locally scoped ...
Note: Jon Skeet sent me a few pointers on simplifying my Linq usage a little - my original code went a little overboard on the query operators. I've amended things appropriately below - thanks Jon! Back in July, I was doing a code review with a team member for a new feature. One of the methods we were reviewing looked like this (Some names have been changed to protect the codebase) private string GetTag(string originalTag, Gadget gadget) { if (gadget.Details.Modules != null) { foreach (Widget widget ...
I often get asked by other developers at work or during presentations about various tools that I use. Most of the tools I use are relatively well known, but I'm going to create this post so that I have a single point where you can download everything without a bunch of Googling. Almost all of the tools on this list are free. My only disclaimer is that this is simply my personal list of the tools I use most often. If you're looking for a *real* list that is extremely comprehensive, then I recommended ...
Tampa Code Camp is coming up in just two weeks, so be sure to register now if you plan to attend. The speaker bios and full agenda haven’t been published yet, but the list of sessions is now available. If you’re going, be sure to check out my sessions: Coding Style and Standards (chalk talk) Code standards and styles are one of those topics that you either love or hate. Join your fellow developers as we talk about what our experiences have been, what worked, what didn't, and why having them is a ...
How do you stay up on new technologies? How do you approach learning a specific new technology? The first thing you have to accept is that the Microsoft technology stack has gotten so vast that it is simply impossible for a single person to be an expert in everything. This is the most important aspect to remember. This post is simply to describe my personal approach for staying up on new technologies in the hopes that other people will find something valuable in this to add to their toolbox. In terms ...
Can't wait to play around with the new Visual Studio 2010. There are some cool stuff coming, including a concurrency troubleshooting tool called CHESS. Many a times, I've felt like I was at the edge of insanity trying to track down a concurrency bug. This tool may come in handy. From Microsoft: CHESS: CHESS is a tool for finding and reproducing Heisenbugs in concurrent programs. CHESS attaches to a concurrent program and takes complete control over the thread scheduling. This allows CHESS to drive ...
For anyone who is interested in learning LINQ, there is a great tool available called LINQPad. It comes pre-loaded with over 200 examples to make learning easier. It is really useful for testing your LINQ queries. And best of all, it is FREE! Download it here ...
If you're in the Kansas City area and you haven't heard about Kansas City Day of .NET (or KCDODN) then you're missing out. KCDODN is Saturday, December 6th at the Centriq Training center. (Go here to register...) Looks like 4 tracks of .NET Developer goodness, including a session by yours truly. GWB'ers Jeff and John will be there as well... so come say hi if you're there. Kansas City Day of Dot Net Development Architecture SharePoint Special Interest 8:00am - 9:00am Registration & Breakfast ...
In this issue: Justin Angel, Shemesh, Albert Eyal, Steve, Ruurd Boeke, Mike Snow, Mehdi Slaoui Andaloussi, Gerard Leblanc, and Jesse Liberty. Also: Steve Smith has opened up a couple new 'feeds' sites that are of note: Azure Feeds and Silverlight Feeds. He has others that you can find info about on these sites but the main idea is to go to Silverlight Feeds and submit your material. I'm mentioning this in good faith that you will also submit to Silverlight Cream of course :) ... yet another source ...
In a recent post, Deepak describes how to generate enums using Linq to Sql and SqlMetal. 1. Generate dbml using SqlMetal. 2. Find reference columns in the dbml that will be used as enums in code. Change their type to the enum name. 3. Generate code using SqlMetal. I find this pretty interesting, but there would need to be some kind of conventions or configuration to denote which tables will be used as enumerations in the code. I think the way to tackle this is to create a custom msbuild task that ...
Topic: Migrating a Data Aware WPF Application to Silverlight 2.0 Presenter: Mike Benkovich, Microsoft Date: 11/18/2008 Time: 12pm - 2 pm Website: http://www.ilmservice.com/s... Abstract: One of the great things about WPF and Silverlight is that they’re both built on top of XAML and with Silverlight 2.0 you can leverage the latest data manipulation capabilities of LINQ. In this session we’ll take a look at a basic WPF application that pulls data from a web service. We will explore VB.NET’s ...
If C# 3.0 was all about Language Integrated Query (LINQ), then C# 4.0 is all about dynamic programming. What exactly does that mean? It means that C# 4.0 brings some of flexibility and declarative style of programming to C#. But what does that really mean? To sum it up in one keyword: dynamic. C# 4.0 is adding a new dynamic keyword which is used as a data type in much the same way the var keyword is used. Why is this important? The biggest reason is that it allows a C# program to use dynamic dispatch ...
As you may have noticed (perhaps on the Visual Studio Start Page), there’s a section of the MSDN reserved for the future of VB. The page is fairly bland at first glance, but there is a great reference to the new features of Visual Basic 10 available in the downloads that I dare say you should investigate. Of the upcoming news, some that stand out are multiline lambda expressions, “implicit line continuation” (AKA goodbye to the underscore, mostly), Auto-implemented properties (one line of code for ...
In this issue: Pencho Popadiyn, Dan Wahlin, Lee, Karl Erickson, Larent Bugnion, Manish Dalal, and Adam Kinney. Jeff Prosise has updated his Enigma Machine: Silverlight Enigma Simulator Updated. Shawn Wildermuth reports he has Updated My Silverlight 2/Astoria MSDN Article. Jesse Liberty is going to be Speaking at Code Mash 2009. David Anson reports he is Shamelessly benefitting from the work of others [Links to Silverlight Airlines and Surface samples for RTW!]... cool ports to SL2. From SilverlightCream.com: ...
/* The Singleton pattern assures that there is one and only one instance of a class, and provides a global point of access to it. There are any number of cases in programming where you need to make sure that there can be one and only one instance of a class. For example, your system can have only one web service manager, or a single point of access to a database. The easiest way to make a class that can have only one instance is to embed a static variable inside the class that A static variable is ...
This code contains a sequential workflow running in a console application. There is a sequence and inside the sequence a QueryActions and ForeachLoop. The QueryActions Activity is a custom activity that you can create through Visual Studio add >> new >> .... etc... it gives you a design surface where you can drop standard out of the box activities. In this case the QueryActions activity has inside of it a standard toolbox DBQuery activity which lets you point and click your way to a database ...
Microsoft.DevelopmentPost msdev = new Microsoft.DevelopmentPost(); msdev.Candidate = this; msdev.DieForProductDevelopment = true; msdev.HasLatestDotNetKnowledge = true; msdev.FollowMsExperts = new MsExperts[] { “Andrew Hejlsberg”, “Brad Abrams”, “Chris Anderson”, "Matt Pietrek" }; msdev.CrazyAboutList.Add(Cr... msdev.CrazyAboutList.Add(Cr... msdev.CrazyAboutList.Add(Cr... msdev.CrazyAboutList.Add(Cr... msdev.CrazyAboutList.Add(Cr... ...