Tag | LINQ Posts

I know I’ve been a bit quiet on my blog lately. I’ve still been adjusting to my new life in Seattle and learning different technologies for my new job. It’s been a lot of fun, but has left me with precious little free time! That said, a few months ago I was invited to throw together some tutorials on Tech.Pro as part of their startup series, so I decided to give it a go. Their site has a nice collection of tutorials of various skill level ratings from several different authors. These were the tutorials ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. I have had the pleasure to program in a variety of programming languages throughout the years including the trifecta of C++, Java, and C#. It's often interesting how these three languages are so similar and yet have such key differences as well. Each of them has ...
There aren’t many applications that are of value without having some for of data store. In Windows Phone development we have a few options. You can store text directly to isolated storage. You can also use a number of third party libraries to create or mimic databases in isolated storage. With Mango we gained the ability to have a native .NET database approach which uses LINQ to SQL. In this article I will try to bring together the components needed to implement this last type of data store and fill ...
Here are the slides for my three presentations this year for the St. Louis Days of .NET 2012. Enjoy them and feel free to share them as you see fit! If you enjoy these presentations, please check out the entire index of my C# Little Wonders, Little Pitfalls, and Fundamentals blog posts which can be found here. Update: Source has been updated to include Saturday’s presentations as well, also added more comments. Also, each of the presentations will have a small pool ball in the lower right hand corner ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. In the .NET 3 Framework, Microsoft introduced the concept of anonymous types, which provide a way to create a quick, compiler-generated types at the point of instantiation. These may seem trivial, but are very handy for concisely creating lightweight, strongly-typed ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. We’ve seen how the Select() extension method lets you project a sequence from one type to a new type which is handy for getting just parts of items, or building new items. But what happens when the items in the sequence are already the type you want, but the sequence ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. We’ve talked about the Select() and Where() LINQ extension methods before. The Select() method lets you project from the source type to a new type, and the Where() method lets you filter the list of items to the ones you are interested in. Most people know of these ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. So last week we covered the Enumerable.Range() method in the System.Linq namespace, which gives us a handy way to generate a sequence of integers to either use directly, or to feed into a more complex expression. Today we’re going to look at another static method ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. Thanks for all of your patience while I’ve been dealing with other matters these last few weeks. I didn’t want to let my post slide a third week, so I decided to say a few words about a small static method in the Enumerable class from System.Linq. Using Range() ...
Recently I was working with data from a generic List<T> and one of my objectives is to get the distinct values that is found in the List. Consider that we have this simple class that holds the following properties: public class Product { public string Make { get; set; } public string Model { get; set; } } Now in the page code behind we will create a list of product by doing the following: private List<Product> GetProducts() { List<Product> products = new List<Product>(); Product ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. I’ve covered many valuable methods from System.Linq class library before, so you already know it’s packed with extension-method goodness. Today I’d like to cover two small families I’ve neglected to mention before: Skip() and Take(). While these methods seem so ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. Today I’m giving a brief beginner’s guide to LINQ and Lambdas at the St. Louis .NET User’s Group so I thought I’d post the presentation here as well. I updated the presentation a bit as well as added some notes on the query syntax. Enjoy! The C#/.NET Fundaments: ...
This blog entry is intended to provide a narrow and brief look into a way to use the Select extension method that I had until recently overlooked. Every developer who is using IEnumerable extension methods to work with data has been exposed to the Select extension method, because it is a pretty critical piece of almost every query over a collection of objects. The method is defined on type IEnumerable and takes as its argument a function that accepts an item from the collection and returns an object ...
Eric Ligman, from Microsoft, posted a great blog post this week listing all of the SharePoint 2010 Virtual Labs that are available from Microsoft. His blog entry is here: http://blogs.msdn.com/b/mss... He also posted other resources as well. I’ve copied his Virtual Lab links here: SharePoint Server 2010 Virtual Labs MSDN Virtual Lab: SharePoint Server 2010: Introduction ...
If you're like a lot of people I've known, worked with, and been, you have a history of either installing Visual Studio (or getting a computer from IT with Visual Studio already installed), selecting a preset option from the "what kind of development work do you do?" menu, and coding away. I spent years occasionally hearing words like "CodeRush" and "Resharper" without really knowing what these things were or giving a second thought to how a productivity tool like them could help my work. A couple ...
Today's $10 book from APress at http://www.apress.com/97814... is Pro LINQ Language Integrated Query in C# 2010"Most books show the simplest examples of how to use a method, but they so rarely show how to use the more complex prototypes. This book is different. Demonstrating the overwhelming majority of LINQ operators and prototypes, it is a veritable treasury of LINQ examples." Adam Freeman is an excellent author who is good at providing practical examples of code ...
The most recent release of LINQ to Twitter included support for Windows Phone. It’s important to note that only 7.1 is supported – the rationale being that 7.1 (Mango) introduced support for IQueryable, which LINQ to Twitter requires. This post will show you how to use LINQ to Twitter with Windows Phone. You’ll see a normal public query, how to log in with OAuth, and how to post a tweet. All of the code in this blog post is included with the LINQ to Twitter source code that you can download at http://linqtotwitter.codepl... ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. LINQ has added so many goodies that can be used to query IEnumerable<T> sequences that it can be easy to lose sight of some of the methods that are unique to each of the collection classes. This week, we will look at the range series of methods in the List<T> ...
I have some basic rules when it comes to checked in code to TFS. The one at the top of the list of rules is that, any developer should get the latest code from TFS, deploy and have a working web part, workflow or any other customization in SharePoint. This means that all dependencies should be deployed with the customization. If the web part uses a custom list as a data source, then a developer should not have to manually create site columns with the ‘correct’ internal and display name, list instances ...
Few days ago I have received an invitation from Packt Publishing to review this book. I myself is a big fan of Generics and is very interested about it, so I've decided to give it a go. Thank you for letting me review this interesting book. .NET 4.0 Generics (Packt Publishing) is written by Sudipta Mukherjee. The book is primarily targeted to beginners and intermediate programmers who want to know what .NET Generics is all about and how it can help solved real world problems. The book covers the ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. First of all, thanks for all the well-wishers for me and my family, things are starting to settle down a bit, so I hope to be able to continue to blog at least on a bi-weekly basis – and I’m hoping to sprinkle in some C++ blog entries as well. But for today, we’re ...
I really love the LINQ language extension in dot net programming and I’m really glad it was added to a language I love (C#). My background, however, has a lot of C++ in it and I still do some coding in C++ – sometimes for fun and sometimes to put back into practice things I should have know for years, but are just now being recognized by my ever-widening eyes. A lot of that new vision comes from seeing C# and LINQ and, of course, practicing all forms of programming MOJO on programming forums, like ...
I ran across a unique scenario recently, and I’m not sure if I should be proud of the solution, or appalled at the Frankenstein result. Either way, I thought I’d post about it to possibly help others in the same situation. I was developing a website leveraging jQuery / AJAX to query views of data at runtime. The kicker? I didn’t know which views. The choice of database view was determined via configuration and user choice. I was leveraging jqGrid for the client-side grid presentation, sorting, filtering, ...
Lambda expressions are a powerful tool to writing quick, concise code. They can be used in numerous situations, most notably in conjuction with LINQ statements.A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.All lambda expressions use the lambda operator =>, which is read as “goes to”. The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression ...
In my previous post, Using LINQ to Twitter in Windows 8 Metro Apps, I cheated a little (some might say a lot) on my UI architecture by using code-behind. In this post, I’ll make it all better by showing you how to separate the model and interaction logic from the UI design – proper separation of concerns. I’ll accomplish this with a pattern, named Model-View-ViewModel (MVVM), which is widely used for WPF, Silverlight, and (soon) Windows 8 Metro Apps. I’ll start by discussing what MVVM is, move to ...
While the title of this post suggests focus on LINQ to Twitter, it also indicates that I’ll be discussing how to build a Windows 8 Metro application. The application itself will display a list of tweets from Twitter’s public feed. In the sections that follow, you’ll read background information on pre-requisites to understanding the post, learn how to get LINQ to Twitter working with Visual Studio 11, and then see a step-by-step on how the application is built. Getting Started You can build Metro ...

Released LINQ to Twitter v2.0.23: http://bit.ly/AoKglP

@JoeMayo

I've been working on a little project recently and one of the requirements was to be able to identify someone's influence in the social media space. I happened to come across Klout which if you are not familiar is a service where people can connect all of their social networking accounts together and it will then analyze your public activity and workout how much Klout you have. Even if you have not joined Klout it still looks at public Twitter information and can rate users just based on their public ...
In a previous post I talked about using the JSON to LINQ features of JSON.NET. Thanks to Bil Simser I was able to do some testing of the deserialization capabilities of this library. The key was his hint to leverage the json2csharp web site. Below is the C# representation of the search results for a Twitter query created by putting an example of the search result into this site. public class Url{ public string url { get; set; } public string expanded_url { get; set; } public string display_url { ...
While adding a new feature to the LINQ to Twitter Search API, I made significant changes to the Search entity that will break existing code. The new feature is support for Tweet Entities, a recent addition to Twitter’s Search API. I’ll cover Tweet Entities support after explaining what has changed. Motivation for Change When Twitter implemented Tweet Entities for their Search API, they only supported JSON format. LINQ to Twitter used ATOM for Search API queries; so, I didn’t have a choice on data ...
This demo is a continuation of my previous article about "Creating a Simple Log-in Form". Basically in this post I'm going to demonstrate the basic on how to edit and update the form with ASP.NET MVC 3. Before you go any further, I'd suggest you to check out my previous article first about "ASP.NET MVC 3: Creating a Simple Sign-Up Form" and "Creating a Simple Log-in Form". STEP 1: Creating the Model class Just for the simplicity of this demo, I'm just going to display the FirstName, LastName and ...
This demo is a continuation of my previous article about "ASP.NET MVC 3: Creating a Simple Sign-Up Form" which I wrote few months ago. Basically in this post I'm going to demonstrate how to create a simple LogOn form in which users can supply their username and password. And how to authenticate and validate users in ASP.NET MVC 3. I will not elaborate more in details about the model, view and controllers function so before you go any further, I'd suggest you to check my previous article first about ...
In the last installment I discussed delegates, which have been in C# since version 1. The problem with delegates in some cases is that having to create separate, named methods to describe the function to be performed can be a bit unwieldy in cases where the method being called is simple and will not be used other than by the delegate invocation. This brings us to a feature added in C# 2.0 – anonymous methods. Anonymous methods distilled down to their most simple explanation are methods that are defined ...
The main way that Twitter provides feeds is through JSON. Unfortunately the version of the .NET Framework that is on the phone does not include the System.Runtime.Serializatio... namespace. Rather than trying to brute force the JSON feed I have been looking into using the Newtonsoft JSON.NET library. The first thing that I ran into with JSON.NET is that the documentation is severely tilted to the serialization side with almost no mention of deserialization. This would have been my preferred approach ...
About a month ago'ish I read some very sad news. Microsoft announced that they were killing off the DryadLinq (or LINQ-to-HPC) project in favor of Hadoop. I was one of the first users of DryadLinq outside of Microsoft, back when it was a pre-alpha project inside Microsoft Research. My company had a running HPC cluster and my boss convinced me to install DryadLinq on it to see what I could make it do. I worked with it for a year, and being a big LINQ and PLINQ fan, really enjoyed how easy it was to ...
Having just help another developer with this issue, I thought I’d write a quick post about the cause of the ObjectDisposedException exception when working with Entity Framework. It is important to be aware of two things when working with Entity Framework 1) The data context must not be disposed of until all the data is fetched from the database. 2) A linq statement creates an IQueryable, which is not executed until you enumerate over it (e.g. use it in a for each loop) or convert it to a list or ...
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} Normal 0 false false false false EN-US X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; ...
In my previous post we started a discussion about concepts that are critical to really understanding LINQ. The next couple of posts will build on the same theme by introducing three very closely related (and somewhat evolutionary) pieces of the C# language – delegates, anonymous functions, and lambdas. My original intent had been to introduce them together in single post, but that would be a rather long post. Delegates are a language feature that have been in C# since version 1 of the language and ...
Daytona - Iterative MapReduce on Windows Azure Overview MapReduce is a framework for processing highly distributable problems across huge datasets using a large number of compute nodes. It is a generic mechanism that comprises 2 steps: Map step: The master node takes the input, partitions it up into smaller sub-problems, and distributes them to worker nodes. The worker node processes the smaller problem, and passes the answer back to its master node. Reduce step: The master node then collects the ...
I’ve been putting a lot of thought lately into how LINQ can be introduced to programmers whose C# skills range from being a fairly new programmer conversant in C# to a seasoned programmer who learned just what they needed to convert skills in another language to C# and the .Net platform and I think that a workable approach would be to introduce first some of the concepts and language features that I view as existing to enable LINQ and then tie them together. The first step we’ll take towards learning ...
Overview Windows HPC Server 2008 is infrastructure for high-end applications that require high performance computing clusters – i.e. for scaling out parallelizable across many compute nodes in a grid. These compute nodes can be coordinated by a head node , which in turn can be proxied via a service broker node that exposes a SOA WCF interface for job scheduling. Additional functionality includes the ability to coordinate between job processes running on nodes via MPI (message passing interface). ...
My friend in Zimbabwe sent me an email a day ago with the following contents suppose i have a table called week_days with only 3 fields i.e. SEQUENCE DAY SALES as follows: SEQUENCE DAY SALES 1 Sun 23 2 Mon 18 3 Tue 30 4 Wed 15 5 Thu 20 6 Fri 08 7 Sat 0 i need a query that converts DAY column to a header row and sort by SEQUENCE as follows: DAY Sun Mon Tue Wed Thu Fri Sat SALES 23 18 30 15 20 08 0 Pliz Help!!!!!!!! I was like’ this looks like a candidate for pivot, but it requires that the result ...
Threading was never so easy since .NET 4 with the TPL has been released. I know I am a bit late but there are so many nice things which might still be new to many of us. The IEnumerable interface has become famous with the introduction of LINQ but many of us have not yet realized that IEnumerable<T> and T[] or List<T> can be exchanged in many cases but there are cases where it is important to fall back to a pure IEnumerable<T> if you want to support lazy evaluation. .NET 4 has for ...
Using a simulated dialog window is a nice way to handle inline data editing. The jQuery UI has a UI widget for a dialog window that makes it easy to get up and running with it in your application. With the release of ASP.NET MVC 3, Microsoft included the jQuery UI scripts and files in the MVC 3 project templates for Visual Studio. With the release of the MVC 3 Tools Update, Microsoft implemented the inclusion of those with NuGet as packages. That means we can get up and running using the latest version ...
Once again, in this series of posts I look at the parts of the .NET Framework that may seem trivial, but can help improve your code by making it easier to write and maintain. The index of all my past little wonders posts can be found here. In the last three weeks, we examined the Action family of delegates (and delegates in general), the Func family of delegates, and the EventHandler family of delegates and how they can be used to support generic, reusable algorithms and classes. This week I will ...
While I have always been a fan of libraries that improve coding efficiency and reduce code redundancy I have mostly been using ones that were in the public domain. As part of the Geeks With Blogs Influencers program a got my hands on ComponentOne’s Studio for Entity Framework. Below are my thought after working with the product for several weeks. My coding preference has always been maintainable code that is reusable across an enterprises protfolio. Because of this my focus in reviewing this product ...
Today I was looking for a solution to get finally the JScript/Javascript/jQuery Intellisense Featureworking with my ASP.Net Webform Project to work. I found some good articles: - JScript IntelliSense Overview- JScript IntelliSense: A Reference for the “Reference” Tag- Enabling JavaScript intellisense in VS.NET 2010 to work with SharePoint 2010- Rich IntelliSense for jQueryBUT, all of suggested solutions did not work right with my Master Page based Visual Studio 2010 Solution.Only with physical Javascript ...
Anonymous delegates are great, they elimiante the need for lots of small classes that just pass values around, however care needs to be taken when using them, as they are not automatically unhooked when the function you created them in returns. In fact after it returns there is no way to unhook them. Consider the following code. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace ConsoleApplication1 { class Program { static void ...
In this Issue: Michael Washington, Oliver Fuh, Jeremy Likness, Derik Whittaker, Jesse Liberty, Jeff Blankenburg(-2-), and Michael Crump. Above the Fold: Silverlight: "Handling Extremely Large Data Sets in Silverlight" Jeremy Likness WP7: "31 Days of Mango | Day #8: Contacts API" Jeff Blankenburg LightSwitch: "LightSwitch Chat Application Using A Data Source Extension" Michael Washington Shoutouts: Michael Palermo's latest Desert Mountain Developers is up Michael Washington's latest Visual Studio ...
So I was asked today how to do cross joins in SQL Azure using Linq. Well the simple answer is you cant do it. It is not supported but there are ways around that. The solution is actually very simple and easy to implement. So here is what I did and how I did it. I created two SQL Azure Databases. The first Database is called AccountDb and has a single table named Account, which has an ID, CompanyId and Name in it. The second database I called CompanyDb and it contains two tables. The first table I ...