Tag | LINQ Posts

I've received some comments and composed some responses, included below: First Comment/Question: I've got questions about performance in LINQ and LINQ to SQL. Is it more effective to create a query against the context or against a collection on another object? For example, which is better: = from t in db.Things where t.Something = "MyVal" && t.ForeignKeyId = 28 or is it better to do this: = from t in db.ForeignKeys where t.Something = "MyVal" ? In the former, I'm running against the data ...
Just thought I'd give you an idea of some of the content that will be presented at the Raleigh Code Camp 2008 this Saturday. Jim Wooley - What's new in VB 9 Richard Campbell - Performance and Scalability Mark Dunn - BizTalk Miguel Castro - How to Work with Recruiters Rob Zelt - Silverlight Bill Jones - LINQ in VS 2008 Josh Carlisle - Customizing MOSS Publishing Brian Gough - Wrapping a User Control in a SharePoint Web Part Josh Carlisle - SharePoint for ASP.NET Developers Kevin Boles - SQL Server ...
I have been working on getting around the concurrency issues that LINQ has while working with disconnected DataContext's in an nTier environment. I currently have a Timestamp field in all of my tables to act as a row version number to help LINQ keep track of what is going on with my data. Up to this point I haven't had any issues as I have been working with objects that were either stored in session/cache as whole objects or I have been reconstituting the object from a new DataContext prior to updating ...
I was aware of lambda expressions because I was reading about them in the C# 3.0 white paper specification, along with other new language features like extension methods, anonymous types, basis for LINQ, etc. I thought it was cool enough, it makes passing anonymous delegates much better in terms of code writing/reading. However, actually using them takes a bit of getting used to. As such, I'd like to give a short example as to how I visualize writing lambda expressions. Consider the following class ...
Glad to say we have upgraded all of main software products to .NET 3.5. So far we have been very impressed with LINQ and WCF. We look forward to play with WWF, WPF, and Silverlight in 2008.
In the way distant past, I ended up creating a new delegate for just about each function I need represented as a delegate. And as I experienced an explosion of delegates and needing to come up with the names for it, I ended up creating 2 sets of delegates as follows: public delegate void VoidFunction(); public delegate void VoidFunction<T>(T argument1); public delegate void VoidFunction<T, U>(T argument1, U argument2); public delegate R Function<R>(); public delegate R Function<R, ...
Read 3 good books this month: 1) the Emotion Machine - by Marvin Minsky - postulates how emotional states are a mechanism for changing the priority weighting of our cognitive machinary in regards to goals and tasks. A fair bit of conjecture as opposed to experimentally backed up theorum, and some rehash of his previous work 'The Society of Mind'. 2) MultiAgent Systems - Wooldridge - design of distributed workflow services that have different goals and tasks, and often which must compete , communcate ...
Countdown till the 2008 launch in Belgium and the start of the TechDays summit has started. Proud to see loads of great Belgian speakers here. Here a list speakers I like, collegeas, community (visug) friends, Microsoft.be guys and other certified trainers and people I met at other Microsoft events. Gill Cleeren : A collegea at Ordina, MVP, SilverLight geek presenting Next Generation Web Applications. Dandy Weyn : A Redmond based SQL Guru with Belgian roots has multiple sessions on SQL 2008. Peter ...
Check out the following from Matt Warrens blog posts, if you are interested on how to implement IQueryable Provider. source: http://blogs.msdn.com/mattw... Part I - Reusable IQueryable base classesPart II - Where and reusable Expression tree visitorPart II - Local variable referencesPart IV - SelectPart V - Improved Column bindingPart VI - Nested queriesPart VII - Join and SelectMany ...
Next Tuesday, Feb. 12th at 5:30pm, I'm presenting at the Arizona .NET Users Group at the Microsoft campus in downtown Phoenix. The presentation is going to be a deep exploration of the new features of C# 3.0 - including LINQ, lambda expressions, extension methods, simple properties, partial methods, anonymous/implicit types, and object and collection initialzers. It will also cover some of the new .NET Framework 3.5 class libraries, but only insofar as they support the C# 3.0 language features (for ...
Egad! So I have used the .First() method in many of my LINQ queries to make sure that my query only returns one record. I thought this would be a great way to insure isolation of one record. Very similar to a TOP 1 statement in SQL. However, there is an issue with this concept. If your TOP 1 SQL statement doesn't find any records it returns nothing. I guess I sort of hoped that the .First() method would do something similar - say return NULL or something like that. It doesn't! Instead it throws an ...
I did some research in the OR mapping capabilities of the ADO.NET Entity Framework with Beta 3. Goal was to see how inheritance works. Here a quick walktrough. Database Started with 2 tables (wich have a 1-1 relationship). Table Employees which holds Name and JobTitle.Table SecurityInfo which holds Username (let's assume that this field is a network login) Entity ModelCreated the EntityTypes in the Entity Data Model as followed. NetworkUsers is inherited from Employee. Here Employees is mapped to ...
ProblemIf you try to query an ArrayList via LINQ you might be surprised to see that its not supported and throwing an exception. In other words the following query will not work at all. ArrayList students = GetStudents();var query = from student in students where student.Score > 80 select new { student.ID, student.Name }; CauseThe problem comes from the fact that LINQ to Objects has been designed to query generic collections that implement the System.Collections.Generic.... interface. ...
I have been working for the past few days to try and figure out how to get LINQ to SQL integrated into my normal nTier environment. I have also been trying to follow along with the general principles of Domain Driven Design but am finding that there are some deficiencies in the current LINQ to SQL implementation that force a few restrictions on how I do things. Let's first look at some of the restrictions Disconnected DataContext My understanding of the LINQ to SQL DataContext is that it prefers ...
This is also from an internal mail to SilverKey Tech Egypt office dev. team. Slightly modified this time! (Yes, I know. I should stop this habit of link collection and get back to writing - hopefully soon) Joe On .NET - Windows Workflow Foundation Tutorial Series SourceMaking (Design Patterns, Antipatterns, Refactoring) Brennan’s Blog » Blog Archive » Intellisense for jQuery in Visual Studio 2008 Happy Coding: OOP and FOOP Linq to SQL DataContext Lifetime Management - Rick Strahl's Web Log Dan Driscoll's ...
Reading the news that Ruby.NET is dead although doesn't feel the best thing to hear, is still logical, and more explicitly it's even "right". After all, it reminded me with the other story about the death of AJAX.NET Professional. I wrote a detailed take on that earlier (in my former blog) and although you might consider this spamming, I feel the same talk needs to be brought back into conversation, because I feel like I want to say the same things, so, I'm quoting it entirely here in this blog. ...
Neudesic is again presenting some great sessions about exciting current and upcoming technologies for 2008 in the Microsoft technology stack. This year, the event is being offered in three cities: Denver, Chicago, and New York. See the NuCon site for the wide variety of sessions being offered across several different tracks, including stuff like Silverlight, Microsoft IO, Team Foundation Server, LINQ, ADO.Net, Enterprise Data, and more ...
It all started with an email Mohamed Hossam (AKA, Bashmohandes) sent to SilverKey Tech. (the company I work for) local office here in Egypt, referring to the article "Foundations of Functional Programming - Part 1 - B# .NET Blog". It inspired me to send few more language links: Linklist 03022008 - Dynamic programming design patterns, Erlang/C# AMQP Client, AOP - Nauman Leghari's Blog James Kovacs' Weblog - Syntactic Sugar, Compiler Candy, and Other Sweets Charlie Calvert's Community Blog : Expression ...
C# 3.0 introduces several language extensions that build on C# 2.0 to support the creation and use of higher order, functional style class libraries. The extensions enable construction of compositional APIs that have equal expressive power of query languages in domains such as relational databases and XML. Part of the new extensions is LINQ. LINQ is a codename for a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual ...
What does Star Wars, "Pour Some Sugar on Me", Beer, Ginger from Gilligan's Island, Socks with Sandals, LINQ, MetaLINQ, and a lack of pants have in common? You'll have to watch Jeff Brand's interview with Aaron Erickson to find out! Back at last Fall's Twin Cities Code Camp, the resident Microsoft DE Jeff Brand did a series of recordings with some of the presenters. He's got them posted up on his web-site now for your parousal. Interesting note: you can't tell, but Aaron is actually not wearing pants. ...
While working on a NIEM parser library I found that you can import XML namespaces at the project level. Previously I posted about doing this at the top of your .VB class file: Imports <xmlns:nc="http://niem.g... That allows you to use the prefix nc: in LINQ queries to work with NIEM documents. Well today I discovered you can add those at the project level. Right click your project and go to properties. In the properties window go to references. Near the bottom you can type ...
Download Solution - OfflineHtml.zip So, one of the cool controls available to us in WinForms is System.Windows.Forms.WebBro... The WebBrowser control is essentially a managed wrapper around some COM interfaces that bind to Internet Explorer and provides us with several interesting capabilities. First of all, one can use WebBrowser to easily display a web page in a WinForms application. All you have to do is set the WebBrowser.Url property and the control takes care of getting the assets from across ...
This very simple extension method makes a string a fixed length. It appends whitespace to a string that is shorter than required or strips characters to a string to is longer than requested. See ScottGu blog post for a brush up (or intro) on extension methods. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ParaPlan.Extensions { public static class StringHelper { public static string ToFixedLength(this string s, int width) { string rv = s; if (s.Length ...
Back Links LINQ Overview, part zero LINQ Overview, part one (Extension Methods) NOTE: This article is dedicated to Keith Elder...even if he never sent me a bologna sandwich. Apparently, two months is my definition of "very soon". Let's continue. Since .NET 1.1 we've had the concept of delegates. They are the constructs that allow us to call methods on objects via reference such as: delegate int AddFunc(int x, int y); public static class MathOps { public static int Add(int x, int y) { return x + y; ...
In the earlier post, we saw the "Dynamic Data Website" shipped with ASP.NET 3.5 Extensions Preview that can be used for rapid application development of data driven websites using Visual Studio 2008. The ASP.NET 3.5 Extensions Preview can be installed from here Once you install the same, you get a few things. One, is that you get the 'Dynamic Data Website' template I talked about earlier. The other thing is that you get the "ASP.NET 3.5 Extensions Website" template that allows you to create an ASP.NET ...
Earlier I had blogged about ASP.NET 3.5 Extensions Preview and also the Dynamic Data Controls and how ASP.NET would be evolving into a comprehensive platform for rapid applicaiton development of Data Driven Websites. While the earlier preview I talked about (Dynamic Data Controls) was a part of the ASP.NET "Futures" CTP, there is now a much better build of the Dynamic Data Controls which we shipped as a part of ASP.NET 3.5 Extensions Preview. Simply putting, we would encourage you to try out the ...
Update: Added more F# samples and the foundations of functional programming In a previous post, I've begun a pretty fun adventure into F#. I'm still working on quite a few samples to post here shortly, but in the mean time, I've collected a bunch of samples that I think are pretty cool and well worth a look. I'm currently digging through Robert Pickering's book "Foundations of F#". I'm especially interested in his DSLs which I hope to cover here shortly. For those interested in the foundations of ...
I have Visual Studio 2005 environment and decided to try VS 2008. I've read some articles(e.g. here) about site-by-site installation and had an impression, that making a copy of solution is enough. NOTE: If you are using TFS, before conversion of the existing solution, obtain and install Team Explorer Client . VS 2005 is using TFS Source Control, but VS 2008 shows no Source Control plug-in installed. . After installing of VS 2008 I've copied my existing solution as MySolution2008 and opened it in ...
Here is simple LINQ example where I have used Extension methods "Where", to select the participants whose score is greater than 80. var participants = Competition.GetParticipants() .Where(participant=> participant.Score > 80) .OrderByDescending(participant => parricipant.Score) .Select(participant => new { participant.Id, Name=participant.Name }); Note: here we are sending a Lamda expression (participant=>participan... as parameter of the "Where" extension method. Ever wondered ...
The "C# 3.0 in a nutshell" book has some neat free extras that are worth mentioning for those who haven't already heard of (they have been released for long). Those are like must-have LINQ tools and helpers. The homepage of LINQKit (the major part of the extras I'm going to cover here) provides great information and short code samples about the components: LINQPad This is a snippet compiler (application to run/try small codes in separation than big VS projects, like this), that's customized for LINQ ...
Inside a C# Program Main() and Command Line Arguments (C# Programming Guide) Types (C# Programming Guide) Arrays (C# Programming Guide) Strings (C# Programming Guide) Statements, Expressions, and Operators (C# Programming Guide) (Anonymous Functions, Lambda Expression, Anonymous Methods) Objects, Classes, and Structs (C# Programming Guide) Properties (C# Programming Guide) Indexers (C# Programming Guide) Delegates (C# Programming Guide) Events (C# Programming Guide) Generics (C# Programming Guide) ...
improve my => 'code' I just started playing around with LINQ seriously, and I really love some of the features incorporated, like the Enumerable.Range() function and how it can be used for integer programming. Here's a simple function for generating lognormal distributions (could be useful for financial engineering). Hope you're enjoying the samples, Jonathan Starr public List<double> GenerateLogNormalDistributi... numberOfTimes, double mean, double standardDeviation) { Random randomGenerator ...
I have been pretty excited about LINQ, because it seems to do all of the optimization for me for free (kinda like T-SQL). Yow Han-Lee asks in his blog, Brainteaser #11, Given any two large List, what is the quickest way to find the mutual intersection of the two? Now take into consideration memory constraints? Well, the answer that only takes a minute or two for me is the following... Comments welcome! Jonathan Starr using System; using System.Collections.Generic; using System.Linq; using System.Text; ...
This week I gave another .NET 3.x session for the syntrawest ITClub developers in Kortrijk. 19 People from West Vlaanderen where interested in Workflow Foundation and liked my presentation. As promised to them : you can download the code of the demos here. BTW : the agenda for my next sessions : 26/02 : VS2008, ADO.NET in .NET 3.5,LINQ 22/04 : Patterns & Practices, Applicaton Blocks and Software Factories 27/05 : Rich Internet Applications with Silverlight Want to attend these events ? Drop me ...
Okay so we've had an onslaught of new things hit in the Microsoft stack lately. I am curious how many folks are using WCF, WPF, WF (workflow), Silverlight, LINQ, etc. And for what types of problems you are trying to solve. It would also be nice to know if you are using the P&P Guidance Packages and Ent Libs. Oh and which Visual Studio version are you mainly working with these days? If you are not using this stuff yet why? Did you pitch it to your boss and they said no for some reason? Did they ...
Now that I'm feeling a bit more comfortable with LINQ to SQL and LINQ to XML, I really wanted to begin exploring the ADO.NET Entity Framework and LINQ to Entities. I started by going to msdn.microsoft.com/data and installed the ADO.NET Entity Framework Beta 3 and ADO.NET Entity Framework Tools CTP 2 (for Beta 3). At first glance, I didn't notice anything new being provided by the Tools CTP, so I started a simple C# Console Application. From the Add New Item menu, I noticed an ADO.NET Entity Data ...
Last week I was present at the MCT Summit in Berlin. Had fun, saw great presentations. A big applaus was given to Marcel De Vries for his LINQ presentation. Which was deserved, this was the best LINQ presentation I had ever seen. Altough the summit was more focused on ITPro and SQL stuff I had a good time. I was introduced by MCT collegeaus to the world of virtualization and Microsoft Hyper-V. Some 400 MCT’s from the EMEA region where there. About 10 belgians quickly joined together and started thinking ...
Update: Added new Hanselminutes show on F# and other links With the new year comes new challenges. Recently I've been looking to take my background in statistics and get back into graduate school. With those days brought the days of functional programming, pattern matching and all sorts of things. So, with that, I began to look at F#. Why F#? No, it's not because it's shiny and new and everyone's talking about it. To a point, it made me more aware, but I won't just hop on the next best thing without ...
Scott Guthrie[MSFT] announced the availability of .NET fx 3.5 library source code as promised. (Setup and how to use) Quote from the announcement: Specifically, you can now browse and debug the source code for the following .NET Framework libraries: .NET Base Class Libraries (including System, System.CodeDom, System.Collections, System.ComponentModel, System.Diagnostics, System.Drawing, System.Globalization, System.IO, System.Net, System.Reflection, System.Runtime, System.Security, System.Text, System.Threading, ...
I felt the need to vent a little bit of frustration today as I spent an entire weekend trying my best to figure out how to get LINQ to SQL to support what I consider to be a fairly standard database design concept - many to many relationships. In my case I have a table of Permissions and a table of Accounts. Rather than storing a list of permissions in my Accounts table I simply wanted to store both Accounts and Permissions separately and then link them together with a linking table. I don't think ...
Scott Hanselman beat me to the punch, but come Feb 14th, our latest and greatest edition of the Professional ASP.NET book is coming out. The book has a ton of new content and was exciting to put together - but man, did it take some serious time to do (especially when all three of us have real jobs, kids, newborns, animals, etc to deal with). The book is big ... really BIG - 1728 pages, so it can serve many other useful purposes after you are done reading it! :) The book description from the WROX.com ...
For those who missed it, our DC ALT.NET group will meet on January 15th at 7PM. I'm hoping for a great turnout of passionate developers in the DC Metro area. Hope you can make it. Also, don't forget to join the list as we discuss more issues and our next meeting stuff. The meeting this month will bring ALT.NET to CMAP. Are you a developer who always keeps an eye out for a better way? Do you look outside the mainstream to adopt the best practices of any development community, including Open Source, ...
GridView! YES! (...1 hour passes...) Dah! GridView! *Fist Shaking* Coming from a Java background I have to say that the standard toolset that Microsoft provides in .NET 3.5 is impressive by any standard. Perhaps the fact that it is standard is what makes it so powerful.... That being said I want to just give a quick rundown illustrating the rollercoaster ride that was my first run in with GridView from .NET 2.0. I first wanted to just populate a table, after a quick googling I landed here: http://msdn.microsoft.com/m... ...
I've been reading lately about what people are interested in with the next version of C#. It's amazing to think how far the language has come from the early days. Many of the newer features of the language with 3.0 by far have made it a better language. So, what did we get with the latest C# 3.0? Object Initializers Automatic Properties Anonymous Types Extension Methods Lambda Expressions LINQ Collection Initializers By far, I agree with most of Jeremy Miller's sentiments regarding C# vNext, including: ...
Lately, I've been evaluation my use of extension methods. Extension methods have a good use, but that can quickly turn to overuse and confusion. The Evil When I start seeing these methods, I really start to wonder if it's really necessary. In fact, I run away screaming with my hands flailing above my head. internal static class ExtensionMethods { public string IsValidEmailAddress(this string email) { ... } public DateTime IsBefore(this DateTime date) { ... } } For readability sake, it's very tempting ...
Anonymous types are excellent addition to .NET “Orcas” release. These are a convenient language feature that allows developers to write code without bothering about what particular type of object they are dealing with. Anonymous types are declared by var keyword which you most of the times will see in different application of LINQ. It's true it great use with LINQ, but it's not a LINQ feature at all - it's a new language feature. A very simple use of Anonymous types is (starting with a keyword var): ...
The following works fine in LINQ, because an array implements IEnumerable <T>. string[] tokenArray = new string[2] { "Hello", "World" }; var tokens = from token in tokenList select token; foreach (var item in tokens) Console.WriteLine(item); But, the collections which do not implement IEnumerable<T> or IQueryable, can not be iterated in LINQ in the same way. To achieve the same, make use of a simple casting trick such as: ArrayList tokenList = new ArrayList(); tokenList.Add("Hello"); ...
I have blogged about ASP.NET "Futures" and Dynamic Data Controls in my earlier post. You could create a Data Driven Website very quickly using the "Dynamic Data Website" template that shipped with the ASP.NET "Futures" July 2007 CTP. However, the ASP.NET Extensions 3.5 shipped in December 2007 bundles a bunch of Dynamic Data Controls that are more powerful and offer more extensibility than the ones shipped with the ASP.NET "Futures" July 2007 CTP. Let me clarify a few things here on the releases:- ...
Hi Folks Decided in 2008 to read a lot more - have a fair bit of spare time and not putting it to much use. I'ts been a while since I read some of code complete 2 and I'm looking for some inspiration - I read plenty of blogs but really want a good book and open to suggestions on lots of differnet topics. I am mainly a Microsft Net developer and I've been looking at Silverlight and Linq mainly but would welcome some suggestions (and reasons for the suggestions) o some good books. Cheers G ...
I have been working on the domain builder but still reading articles and blogs. While I still love the idea and the concepts, the MVC presentations are really slick. I think that I am going to change direction just slightly and focus on the MVC pattern from Microsoft. I still plan on having CSLA and NHibernate talking together. I just read another article on Ayende's site about having NHibernate using LINQ. I will explore this further as well, but right now my focus is getting the MVC pattern talking ...