Tag | LINQ Posts

I've gathered some data into an object and then done a Linq to that object using code a bit like this: //Linq query var q = from c in objFlist.Items orderby c.Surname select c; List<clsFileInfo> listOfItems = q.ToList<clsFileInfo>(); GridView2.DataSource = q; GridView2.DataBind(); That works fine as long as I let the Gridview organise itself from the data automatically. To make it more polished I wanted to lay out the columns in the Gridview and add template columns etc. To do this I ...
Yesterday I gave a conference on LinQ to Objects at the .NET Montreal Community. The format was not your typical conference, it was a coding dojo! Everything went well and I think many people enjoyed to event. I'm posting a link to the solution that contains all the exercices the group did with the the answers included. Unfortunatly, it's in french :) If someone would like to have the exercices in english, about 20 of them, please post a reply and I'll put the english version here ASAP... Have fun! ...
This article is a two-part series regarding the LinqToWikipedia provider. The first article will cover the basic concepts of Linq as well as the client usage of this particular provider while the second article will explore the inner workings of the LinqToWikipedia provider to give you an understanding of what it takes to create your own IQueryable provider. NOTE: You should download the latest build from Codeplex so you can follow along with the code samples. What is Linq? Let's spend a moment and ...
Common questions when learning LINQ to SQL revolve around many-to-many relationships. This post will describe a scenario that needs queries across many-to-many relationships, show the data and the LINQ to SQL representation of that data, explain the query, and finally output the results. As you know, the design for many-to-many involves a join table. The following figure illustrates a many-to-many relationship between Tags and Tasks with a TasksTags join table: A scenario for working with this data ...
Hi this Article is aimed at discussing only the outlines of ASP.NET DataBinding. ASP.NET provides a rich set of controls for working with data.ASP.NET provides the DataBound controls,DataSource Controls to work with data. DataBound Controls : We can use DataBound Controls in our application's to generate the user interface for working with data.The DataBound Controls are used to display the data and modify the data. There are three types of DataBound Controls are available. List Controls Tabular ...
This is a new blog on the first day of the year starting a new decade. The world has changed in the last 10 years and the software development we did in 1999 is much different than the software development we did in 2009. In the same spirit, the next 10 years will see dramatic changes in the way we write software and the platforms that software runs on. Moving from compilers that targeted operating systems to targeting virtual machine platforms as mainstream software engineering was a dramatic change, ...
I like using ASMX Web Services (WS)in my code -- either creating them or just calling them. (Yes, I use Windows Communication Foundation (WCF) also). One of the best features of the WS call is that the object model can be exposed to allow the caller to return specific results that need no additional parsing. This does not hold up, however, if the result is returned in a string of raw XML as the result may require additional parsing to be of best use. Here is an example of calling Web Services where: ...
Wow, it only seems like just last week I was sitting at my PC trying to determine what I was going to concentrate on in software development for 2009. I had also just started the Frederick .NET User Group (FredNUG) in September 2008 and I was trying to figure out how to get speakers scheduled. Then, things started to quickly fall into place. My local INETA mentor, Frank La Vigne, provided me with a few names of well respected .NET MVPs who would most likely be interested in speaking at FredNUG. (Thanks ...
[Discalimer] This is just fun code and nothing too serious. Anything bigger than this should be hosted on a site where others can contribute. [The Story] A while back, someone asked a question on Twitter concerning LINQ to XML. I made a small example then as a proof of concept, then i kept playing with it until I came up with a lite framework for a utility that can be used to search and download DotNetRocks podcasts. Right now, the utility is a stand-alone command-line app, but is written in such ...
Recently I had an interesting task to consume a particular XML document and populate a C# object from it. The structure of the XML document looked roughly like this: 1: <root xmlns="http://www.w3.org/20... 2: <entry> 3: <id>1</id> 4: <title>abc</title> 5: <content> 6: <div xmlns="http://www.w3.org/19... 7: <table> 8: <tr> 9: <td>Item1</td> 10: <td>111</td> 11: </tr> 12: <tr> 13: <td>Item2</td> ...
Now that we have some basics for LINQ for XML. Lets get deep into some using LINQ against Relational databases, aggregate functions, like group by and sort. The database we will be using is books, this can be obtained from this page. Once you download the database, mount it in SQL Server by attaching this mdf file. Once the mdf file is mounted, we can start with the following steps to do our first LINQ to SQL console program. 1) First of all we need to add a new DB by selecting Tools > Connect ...
Now that we’ve got some basics of LINQ for XML. I think we should also look into group by queries in LINQ for XML. My motivation here would be to find the total price of books for each of the genre. For this, I should write LINQ something similar to this below: var query3 = from p2 in query_1 group p2 by p2.Element("genre").Value into b1 select new { Value = b1.Key, Price = b1 }; We group by particular node value using group p2 by p2.Element("genre").Value into b1, here b1.Key will give you the distinct ...
I find it interesting how people think... what makes sense to them, et.c so... There's how I think... SomeObject.ListOfPeople.Fin... type => type.GetType().Equals(typeO... (person => { DoSomethingWithPerson(arg1, arg2);}); Pretty straight forward lambd Final all of x type in this collection and then do something to each one found. But coworker suggested this instead: (from person in SomeObject.ListOfPeople where person is Individual select person as Individual).ToList().ForEac... ...
If you have used the Entity Framework that shipped with Visual Studio 2008 SP1, you would really start appreciating the flexibility it offers for building schema driven data access layer and get it to the UI Layer either directly or using a middle tier such as WCF RIA Service. Check my earlier post on this, if you are interested further :) Meanwhile, the other exciting stuff that has been around is the SQL Azure which is part of the Windows Azure platform. SQL Azure provides relational data over ...
The next version of Entity Framework has many new features, many of which are enabling it to catch up with features previously available in other frameworks like LINQ to SQL. One of these new features is the updated stored procedure support. In previous versions of EF, working with stored procedures was quite limited and really only usable with CRUD operations that were mapped to already defined entities. With EF 4, you can start with your stored procedure and have the designer automatically generate ...
I have been playing with the WCF RIA Services (erstwhile .NET RIA Services) for sometime and found that most of the samples out there focus on Silverlight based applications. While the new WCF RIA Services preview for VS 2010 is awesome in terms of its Silverlight integration, I also wanted to test out on building plain vanilla ASP.NET Applications and using the power of WCF RIA Services to build a middle tier for the same. Ok, to begin with, I already had Visual Studio 2010 Beta 2 installed and ...
Technorati Tags: LINQ PLINQ: LINQ, but Faster! Parallel Language Integrated Query (PLINQ) in the Microsoft .NET Framework 4 offers a minimal-code solution to take advantage of this parallel hardware, providing an implementation of the .NET Standard Query Operators that uses parallel execution techniques underneath the simple LINQ programming to make applications run faster! Come for a deep dive into PLINQ via Microsoft Visual Studio 2010. See what it looks like from the perspective of LINQ developers, ...
Technorati Tags: Application Architecture and Design Strategies,Silverlight,Para... Programming,Tutorials The MSDN Southern Fried Roadshow is a developer/architect training through the southeast, presented by technology evangelists Chad Brooks, Glen Gordon and Brian Hitney with Microsoft. Dec. 8 2009. Introduction to ADO.NET Data Services The new wave of Web applications are built on AJAX and Microsoft Silverlight. We learn how ADO.NET Data Services enables applications to expose data as a REST-based ...
This post aims to dissect the power that exists in the Aggregate LINQ operator. I have realized that most programmers use it sparingly and have decided to put a couple of examples to clarify how you can use the Aggregate operator to perform a few tricks. The screenshot below relates to the small examples that follow. The aggregate operator is interesting in that it enables accumulation of items to form some result. This comes in handy when we need to create new data items from others. In my examples ...
In previous versions of TFS, you installed TFS Team Build on the build server and you got one build service agent. It was/is possible to start several build agents on the same server, but it is a bit of a mess. In addition, for each team project TFS 2008 build service can only execute one at a time (Note that builds from different team project can execute in parallell, a lot of people still don’t know this) In TFS 2010, the concept of build controllers were introduced. A build controller belongs ...
Well... Hello. People that know me know that back in 2005-2006 when I used to work for a consultancy company I used to have a technical blog and it was useful not only to be in touch with other developers but also to post code that was useful to me even over and over. You can still find that old blog in http://consultingblogs.emc.... After I left that company I spent some crazy 18 months developing one of the coolest systems I have ever worked on for a big American futures broker ...
Step 1 Install Visual Studio 2010 Beta 2 http://bit.ly/vs2010b2 TIP: This works great inside Windows Virtual PC (10MB download) on Windows 7 if you want to avoid using it on your main machine Step 2 Install ADO.NET Entity Framework Feature Community Technology Preview 2 http://bit.ly/ef4ctp2 TIP: The CTPs give you additional functionality such as self tracking entities – which you need for N-Tier work Step 3 Install the beta of LINQPad for VS2010 Beta 2 http://linqpad.net/Beta.aspx TIP: I recommend ...
Last night (3rd Dec 2009) I was lucky enough to be speaking at my local (and most excellent) user group http://www.dotnetdevnet.com/. There were plenty of mince pies and lots and lots of swag to give away – plus great questions and chats in the breaks. Thoroughly enjoyed it. Slides: Entity Framework 4 In Microsoft Visual Studio 2010 - ericnel View more presentations from ukdpe. Links from the session: Install VS2010 Beta 2 http://bit.ly/vs2010b2 LINQPAD beta for Visual Studio 2010 Beta 2 http://linqpad.net/Beta.aspx ...
With .NET 4.0 right around the corner, I thought it would be cool to download Visual Studio 2010 beta 2 and start playing around with the next release of Entity Framework. The initial release of Entity Framework came with a great deal of criticism. To make matters worse, there was a large uproar when it was rumored that Microsoft would be abandoning LINQ to SQL, in favor of Entity Framework. This was because, at the time, many developers felt Entity Framework was an inferior technology to LINQ to ...
It looked like we should look a bit about LINQ fundamentals before we actually get into the core programming for our Silverlight twitter application. So we’ll look into LINQ for a few more posts, then we will proceed with our usual Silverlight stuff. Line INtegrated Query allows us to use Query language to select data from almost any type of data sources like XML, SQL, Objects, etc.... For more information about LINQ, visit this page, I don’t want to get deep into the details. You can get the sample ...
Just a small bit of code, I've been playing around with converting some Xml* code to Linq to Xml code, and pretty successfully achieved everything I wanted, one thing missing was the ability to retrieve an XElement ignoring case. First - I'd like mention that yes I know Xml is case sensitive - and this is a bad thing to do - but I needed to do it due to some wierdness in the input xml... Anyhews, below is the extension method I wrote to deal with this.. public static class XElementExtensions { /// ...
Between work, life and umm... more work, I haven't really had much time for blogging *lately. (*for varying definitions of lately, the most accepted being "several months.") It hasn't helped that 99% of the random crap I usually spew onto this blog could apparently be summarized in 140 characters or less. Looking back, I guess Twitter damn near killed this blog. That and being **extremely sick over the last few weeks didn't help much either. (**Diabetes sucks, whether you ignore it or not. I've tried ...
I just love Linq in SharePoint. I think it is just an awesome way to write quick queries and get at data quite quickly. I've been working with it for a while on several projects and have been seeing some quirky things with it. First, the one problem that has been blogged about the most is that linq does with SPSite and SPWeb objects do not get properly disposed after they are used. You can google around for these issues and fixes. I implemented extension methods that properly disposed of the SPSite ...
Soo… Long time no write… A quick project was assigned to me and two other guys at work the other week – one of those quick 2-3 day projects, the ones were speed is paramount. Quality can be worked on after release… Sooo.. 3 parts, 3 of us, we split it 3 ways and all was good – one on database duty (using LINQ to SQL), one on UI (Adobe Flash 10) and me, on WCF service… All was going well, the database was up and running, I was using the libraries to interact it with it without any problems, then we ...
Career/Skill Path Each individual is playing different roles. Some are software engineer, some are programmer, tech lead, architect, project manager and so on… How would your skill to develop over a period of time so that you can take the next step and will prove to be true to your designation. Here are some of the check list… Check what skills you have and develop the one which you don’t currently possess. It’s not just about superficial skill, but true skill I am talking about. Don’t go over the ...
Lately I’ve been working with EF 4.0 and finding that many of the new features are catching up with the features previously available in other framework like LINQ to SQL. One example of this is the ability to easily attach objects (for example, disconnected objects that come in from another tier). For example, imagine you had a web service where a consumer submitted an object to get saved – you’d want to instantiate a new context, attach the incoming entity, and save the object. In previous versions ...
Welcome to the 2nd series of building a blog engine. In the first part we have laid out the foundation for this application and modeled the DB structure for quick mockup. You can read the first part here lets-build-a-simple-blog-en... One thing I missed to mentioned in the first part is the we will be using the excellent ELMAH for error logging. This is a pretty cool module which hooks up to the system and logs all exceptions without writing a single line of code. You can read more ...
Two areas I am looking at right now are SQL Azure and Entity Framework 4. PDC had plenty of content on both these areas. Just need to find the time to watch some of it! I have added direct links to the standard definition WMV and the PPTs to download (which is what I am doing right now). SQL Azure SQL Azure Database: Present and Future Windows Media Video PPT Using the Microsoft Sync Framework to Connect Apps to the Cloud Windows Media Video PPT The Future of Database Development with SQL Azure Windows ...
En mi trabajo actual casi no utilizo el SQL Manager. Esto debido a que yo sólo me encargo de cosas del front (funcionalidades e interacción con el usuario) y lo referente a bases de datos lo ve otra persona. Estarme alejando de las cuestiones de bases de datos me preocupa un poco porque siento que podría 'oxidarme' en esa área que de por sí no ha sido mi fuerte; sin embargo, hace algún tiempo me dí cuenta de que en realidad la persona que se encarga de bases de datos tampoco le mete mucho la mano ...
So in response to some comments on my original post on this topic, I started playing around with some other ideas. I figured it would be cleaner to post code here, rather than the comments. How many variations on the theme can we really have? As suggested in the comments on the previous post: 1: public static string Join1<T>( this IEnumerable<T> items, string delimiter, Func<T,string> converter ) 2: { 3: return string.Join( delimiter, 4: items 5: .Select( converter ) 6: .Where( ...
Recently my company just released the first version of a new MVC web site: AlbumCredits.com. This project, led by Oskar Austegard, is was I consider a highly successful real-world implementation of MVC. In a time when most music these days is downloaded, the production and performance engineers, and recording professionals that work on the music don’t always get credit because there is no CD booklet to look through. Album Credits is almost like a LinkedIn for recording professionals. From the about ...
Microsoft has just released the November CTP (CTP 3) of StreamInsight. See http://www.microsoft.com/do... I've encountered some confusion from more than one person about the status of StreamInsight, so let me explain briefly that a CTP is a Community Technology Preview. It's not a beta as such. CTPs are closely aligned with the shorter iterative development cycles of agile methodologies. Many Microsoft product teams ...
If you’re planning on being at Windows 7 Developer Boot Camp (already sold out) at PDC 09 next week come check out the “Lunch with the MVPs” scheduled from 12:00-1:15. We will be having several tables where you can come over and have (informal) conversations on a wide range of topics including: MVC, RIA, Silverlight, XNA, LINQ, and more. I will be leading the table “MVC in the Real World” so come check us out. Hope to see you there ...
http://dotnetradio.com/arch... Andrew sits down with Atif Aziz. Atif Aziz is a senior IT business analyst at Cargill International and an ex-Microsoftie. His primary focus is helping customers move to the .NET Framework. He speaks regularly at Microsoft conferences and can be reached through his web site. You can find out more about Atif Aziz by visiting his web site www.raboof.com. Raboof.com = FooBar!! Atif describes to us what ELMAH is and the history behind it. He then ...
Going into the whole podcasting adventure was something that I didn’t know if I was ready for or not. I won’t lie, it has taken a LOT more time than I had initially estimated. But getting the opportunity to meet and interact with the people that I have has been wonderful. I thought setting up interviews, given that the site is new, would be difficult. As it turns out getting people to come on the show has worked out quite well. So much so that people are now asking to come on the show directly. Wonderful. ...
Thanks to everyone who attended my LINQ to SQL presentation at RockNUG last night. The code samples can be downloaded here: LINQ to SQL demo code. As a point of clarification from last night’s Q&A session after the presentation regarding using LINQ to SQL with true POCO classes that do not even have [Column] mapping attributes, you can have a class like this: 1: public class Contact 2: { 3: public int ID; 4: public string FirstName { get; set; } 5: public string LastName { get; set; } 6: public ...
Tomorrow night I’ll be at RockNUG presenting LINQ to SQL. Yes, LINQ to SQL. Again. In the last 2 years I have presented LINQ to SQL numerous times at various user groups and code camps. Why do I keep getting asked to present LINQ to SQL? Isn’t LINQ to SQL dead? Answer: No. LINQ to SQL is not dead! This confusion all started back in October 2008 with a seemingly innocuous post on the ADO.NET team blog discussing the emphasis that Microsoft was going to put into the Entity Framework going forward. ...
This text is based on the Chris Pels video and code located here. ASP.NET Membership mechanism allows to use the build-in server tables to store and retrieve user data. By default, this mechanism can only be used with SQL Server database to which Microsoft provides suitable MembershipProvider class. Inheriting from this abstract class, developer can use his own table(-es) from any database and use any database engine other than SQL Server, like Oracle, DB2 etc. In this article I would like to show, ...
In the first post in this series, I provided a little info on the HandleError attribute in MVC 1. In case you don’t want to flip back, the HandleError attribute can decorate a method or a class and will push your users to a generic errors view provided customErrors is “On” or “RemoteOnly”. There’s a little more to it, but that’s all the background we need for this post. The out-of-the-box HandleError attribute works well, until you’re in a scenario where you need to do more than hide your errors. ...
BACKGROUND Recently, I have been working on Windows Workflow Foundation. We are trying to create a custom host for workflow, and this workflow host is supposed to have a facility, such that it shold be able to provide a way to resume from the exact point where a workflow failed from the Admin UI. Something similar to the Biztalk HAT. Well, having said that the question how can something like this can be achieved ? What I am going to present here is one of the ways of achieving it. There would be ...
Lets examine the dynamic key word introduced in .Net 4.0. It can keep an instance of any type. Then what is the difference between it and System.Object. Well the essential difference between them is the dynamic method dispatching which enables lazy binding, i.e. it allows you to write method, operator and indexer calls, property and field accesses, and even object invocations which bypass the normal static binding of C# and instead gets resolved dynamically. It provides a unified approach to selecting ...
I just got through interviewing Atif Aziz (@raboof on twitter – foobar spelled backwards!) probably most known (at least to me) for his ELMAH (Error Logging Modules and Handlers) contribution. We discussed ELMAH, ELMAH’s Veracode Application Security Rating which made OWASP top 10 in 2007 and SANS-CWE top 25, Fizzler, Jayrock, BackLINQ, LINQBridge, and MoreLINQ. Atif is a very smart guy and you can truly hear his passion for sharing with the development community when speaking with him. This was ...
As far as I have seen content controls in Office 2007 render to either a SdtRun or SdtBlock object. The nice thing is that both of these inherit from SdtElement. This allows you to take the query from my earlier post and replace SdtBlock with SdtElement and now you have a universal retrieval. Of course as with any tool you need to be careful you don’t take it too far. Depending on the structure of you document this may not do what you need. Technorati Tags: office Open XML,OOXML,LINQ,.NET ...
I thought it would be useful (at least to me!) to summarise the new stuff in Entity Framework 4 given it actually comes in 2 parts. The list is a simplified and categorised version of this and this. General Foreign Keys now added: EF 4 now includes a new type of associations (Foreign Key Associations) that allow you to have Foreign Key properties on your entities. They are the default although the EF v1 Independent Associations remain. Lazy Loading on by Default in new Models: Also name change from ...