Tag | LINQ Posts

Check out the new features in SharePoint 2010. Really cool stuff. I highly recommend watching the video here. The cools stuff I remember is LINQ for SharePoint !! how cool is that? no more CAML queries.. blur....anyway watch the presentations that show easy it is to deploy a WSP file into the dev SharePoint page. .. I love it.... For more info on how EMC Application Consulting Services can help you get ready for SharePoint Server 2010 please contact me through this blog Harish Pavithran. Developer ...
Let's say we neede to process a bunch of entities coming from an XML file, create EDM entites for each XML element and eventually persist them. Very trivial to accomplish using a little bit of LINQ. <Roles> <Role name="Admin"/> <Role name="Reader"/> <Role name="Writer"/> </Roles> var doc = XDocument.Load("Roles.xml"); var roles = doc.Element("Roles").Elemen... => new Role { RoleName = (string)x.Attribute("name") }); PermissionsAPIContext context = ...
So over the past few months I have hit so many bugs and errors coding in .NET, that I thought I’d share a some of them that I spent several hours trying to fix, only to realize it was a simple solution. This will be a multi-part series, if all goes to plan. LINQ Error: “Row not found or changed”. This one took some head scratching. It’s a pretty generic error, and unfortunately the internet wasn’t of great use to finding the answer. I use timestamp columns in almost every table, since it makes updating ...
In this Issue: Ryan Shelby, Silverlight SDK, David Poll, Jesse Liberty(2), Scott Marlowe, Brad Abrams(2), and Katrien De Graeve(2). Shoutouts: Hannes Preishuber shows how to find the Silverlight 2 Design surface in VS2008: Silverlight 3 Visual Studio 2008 Designer Preview . Josh Santangelo was involved in Project Tuva and he has a bunch of good info up: Project Tuva Post-Mortem. On July 30th, Brad Abrams is going to give a Virtual talk at the Linked .NET User's Group on all the goodness he's been ...
Speaker Tim Huckaby is currently focused on RIA & Smart Client Technologies like WPF, VSTO, Surface, and Silverlight. He has been called a “Pioneer of the Smart Client Revolution” by the press. Tim has been awarded multiple times for the highest rated Keynote and technical presentations for Microsoft and numerous other technology conferences around the world by Microsoft Corporation. Tim has done presentations on Microsoft Technologies at technology events like Microsoft Tech Ed, Product Launch ...
I've noticed in my LINQ code Resharper Warning "'Access to modified closure'". The search pointed that there is very confusing potential error. If for/foreach loop variable is used only in Linq methods (more general, only as a parameter for delegates) , only the last value of the variable will be used for all calls. It always required to create local variable inside loop and use the local variable instead of loop variable. More about the issue: Linq: Beware of the 'Access to modified closure' demon ...
Incorporating the jQuery Grid With ASP.NET MVC Scenario: You have an ASP.NET MVC application and don't want to custom build smart controls like the ASP.NET GridView, ListView, etc, that support sorting and paging, as well as filtering and searching for data, and all of this using Ajax. Solution: The jQuery Grid plug-in. What tools/plug-ins do I need? jQuery version 1.3 and up jqGrid version 3 and up (this post references version 3.4.4) A strong cup of coffee In the past you had to also add the jQuery ...
This show is a bonus edition. It includes a brief overview of the announcements this week around Azure at the Worldwide Partner Conference in New Orleans and then a 30minute interview recorded at Qcon 2009 in London earlier this year. This time around, I am the interviewee for a change. Many thanks to Ryan Slobojan and InfoQ for letting me take the original video interview and create a podcast from it. If you prefer, you can watch the video on the InfoQ site. I was asked the following: Eric, what's ...
In this Issue: Jacek Ciereszko, Unni, Mehdi Slaoui Andaloussi, Bea Stolnitz, John Papa, Expression Blend and Design Blog, Andrej Tozon, Christian Schormann, and Jeff Blankenburg(2). From SilverlightCream.com: How to connect from html to Silverlight and from Silverlight to html Jacek Ciereszko provides a down-right clever little app demonstrating what his article is all about. And if you can read Polish, he has a link out to his blog! Introducing sample data for Developers Did you know you could design ...
Allow me to quote here some emails I sent to the the Dot NET developers group in my company, Injazat, or, as we call ourselves, Ninjazat. I thought it’ll be useful to share some with you as well. · ASP.NET MVC - 20 Hours of FREE Video Tutorials · LINQ FAQ o LINQ FAQ for Newbie’s o LINQ FAQ Part 2 · How we handle application configuration · ScottGu ASPNETMVC Session Video Available Now (Part 1/2 & 2/2) · Web Validation: Best Practices and Tutorials · Building a Single Sign On Provider Using ASPNET ...
Have you ever noticed the goofy logic that must be used to do simple things like creating a comma-delimited string? public string CommaDelimit(ICollection<... strings) { StringBuilder sb = new StringBuilder(); bool first = true; foreach (string s in strings) { if (first) first = false; else sb.Append(','); sb.Append(s); } return sb.ToString(); } This method should be hidden away in a static method, and in fact this kind of logic is hidden away in a static method. String.Join() will create ...
Mother of all Blog Posts Building expertise in WPF / Silverlight · Core Programming Concepts: Declerative programming, Dependency properties, DataBinding, Commands, Triggers, VSM, Control templating, the inheritence model , XAML extensions and control templating · Transforms and animations - SVG experience helps · Comprehend the core differences in SL and WPF- lack of Commands and Triggers (Behaviours and VSM are superior anyway), Calling different types of services (WCF, Sockets, Duplex, ADO.NET ...
Recently I have been doing some work on an older system using ADODB recordsets. Every now and then we still have to support these old systems. I wanted to create an open recordset in code on the .NET side to pass to the older system, but ADODB really wants an open database connection in order to open a recordset. My first obvious attempt was to create the recordset object, then create the field objects and add them to the recordset. I could create the recordset this way, but I couldn't open it, and ...
In January and March 2009 I presented to the East Bay .NET and San Francisco Bay .NET user groups respectively on how to build business applications in Silverlight. The theme of the presentations was to show how developing line of business applications in Silverlight is extremely similar to other technologies like Win Forms, WPF or ASP.NET. I demoed how to build a simple CRUD application in Silverlight hitting a SQL Server database over WCF. The building of the application during the presentation ...
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Xml; using System.Xml.Linq; using DocumentFormat.OpenXml; using DocumentFormat.OpenXml.Pack... using System.Text; using System.IO.Packaging; using DocumentFormat.OpenXml.Word... /// <summary> /// DocumentExtensions contains functions to manage the creation, reading and writing of XDocument objects /// that come from an OpenXmlPackage /// </summary> ...
Normal 0 MicrosoftInternetExplorer4 /* 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-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.000... mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman";} Normal 0 MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; ...
In this Issue: Erik Mork, Colin Eberhardt, Nigel Sampson, and Alex Golesh. Shoutouts: Pavan Podila has a post up about a great-looking TreeMap he's done. He may post source later, I'll watch for it. Meanwhile read the post and watch the video. A SilverLight TreeMap control From SilverlightCream.com: Commanding in PrismErik Mork interviews P&P members Bob Brumfield and David Hill along with Shawn Wildermuth all discussing Commanding in Prism ... another great Prism Podcast Erik!Silverlight MultiBindings, ...
ADO.NET Data Services provides a robust REST API over top of a data source. That data source could be 1) the Entity Framework (EF), 2) LINQ to SQL, or 3) your own custom data source that implements IQueryable and/or IUpdatable. However, it should be noted that in v1, EF is really the “first class” data source for ADO.NET Data Services because it supports both IQueryable and IUpdatable out of the box. In this post I’ll discuss the scenario where you have inheritance in your entity object model and ...
Here’s a refactoring I used to do some minor cleanup today. The programmer was iterating through a dictionary to add values to a list. No logic was contained within the iterator. public void AddCodes(Dictionary<int, string> indexedCodes) { foreach (var code in indexedCodes.Values) { Codes.Add(code); } } This can be simplified by using the list’s AddRange method. public void AddCodes(Dictionary<int, string> indexedCodes) { Codes.AddRange(indexedCodes... } If you’re reassigning, this ...
So, somehow within the past five years I’ve mapped out my life to lead to a point where I’m sitting here blogging on GeeksWithBlogs.net. I never would have guessed it…lol There’s no need for me to sweat it though. I’m a 23 year old IT college graduate that has a full time software development job, an amazing family, a loving girlfriend, and incredible friends. As one of my co-workers recently put it: “I’m livin’ the dream” :) I'm a former employee of iPay Technologies and currently work for Republic ...
Microsoft Community in Bangladesh proudly presents Microsoft Day @ Dhaka. This is a special day dedicated to all Microsoft technology professionals and students in Bangladesh. We will be having the best Microsoft community technologists from Bangladesh - Microsoft Most Valuable Professionals (MVPs) delivering sessions at the event. This technology marathon is a great opportunity to learn from the best and network with each other. Both Microsoft developers and networking professionals would find the ...
I finally had a chance to install VS2010 Beta 1.Full instruction on how to here VS2010 has undergone a major overhaul since VS 2008, a peek are some of the cool new eye candy can be found here I've been waiting to get my hands on the TPL/PLINQ stuff and the Beta was definitely worth the wait. In a previous post we talked about using asynchronous actions for performing long running operations. I was anxious to see how the new TPL stuff would help in achieving the same thing. Interestingly enough, ...
Been a little while since my last blog post. For awhile I was busy preparing my presentation for the COSPUG Show-N-Tell event and then recently working extra hours for some releases to testing and UAT at my client. That aside I’m ready to get back to some more regular posts. Yesterday myself and a coworker Peter travelled down to Mason, OH for the CINNUG (Cincinnati .Net User Group) ORM FireStarter event. This was a full day event talking about various ORMs (object relational mapping) frameworks ...
1. Error Message : Only parameterless constructors and initializers are supported in LINQ to Entities: The following query works perfetcly with LINQ: NoticeRecipient rec = dc.NoticeRecipients.Where(o => o.RecipientID == new Guid(id)).FirstOrDefault<... But the same query will give the above mentioned error with Entity Framework. The issue was using new Guid() inside lambda expressions. You have to change the query as follows. Guid gID = new Guid(id); NoticeRecipient rec = ...
Taking advantage of language features can make sleeker, easier to maintain code. One of these language features are array initializers. Have you ever created an array, then assigned each element in the array? This incurs many lines of code with no tangible benefit. Check out this code from the NameMangler class in LINQ to XSD. Read More ...
How often you should search for the various information? Most likely it occurs every day. It is important, that an information search problem not trivial. Also the information can is in various sources - in files, in e-mail messages, in documents etc. Not the secret, that most part of an information is in a network - local and global. Windows Search which allows to search easily and conveniently on the basis of indexes has been developed in Windows Vista. In Windows 7 a theme of search has found ...
One of the big areas of improvements coming to Visual Studio 2010 and .NET Framework 4 is in the area parallel computing. There are a LOT of new features and improvements to existing features here with this latest release of our developer tools. Many people smarter and more capable than I have already written about most of this stuff, so there’s not much for me to add. What I did want to do though is to let you know all the places where you can find this wealth of information (and there is a lot ...
If you're getting this message: The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934... C:\Documents and Settings\pldital\My Documents\Visual Studio 2008\Projects\PatentableSer... ... add... System.Data.Linq as a reference to your project. I still get bit every once in awhile (read: pasting together a poc) ...
Back in March I presented at Qcon 2009 in London which is a great conference. I also was interviewed which is now up on InfoQ. TBH – it isn’t a bad interview yet at the time it felt awful right from the first moment when after agreeing the opening question before the camera rolled, I got asked something completely different :-) Then it went pretty broad :-) You can watch the video on the InfoQ site which includes a transcript. The questions I was asked were: Eric, what's going to be coming up in ...
One of the cool things about ASP.NET 4.0 is the Query Extender and the ability to search within DataContext without using WHERE clause, writing extensive code etc., It works on the new set of namespace i.e. “System.Web.UI.WebControls.... namespace. I am trying to put up an extensive sample using QueryExtender in the next post, but for this post, I wanted to share an error that you might hit when trying to implement the Query Extender control with Search Expression, Range Expression etc., ...
Normal 0 false false false MicrosoftInternetExplorer4 /* 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-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.000... mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} If you are planning to choose ...
Not too long ago, I spared some time to discover the hype of LINQ, primarily, LINQ to SQL. I was amazed of how much faster I could get things done with much less code. In fact, I’ve converted much of Glacsy.com to using LINQ and have noticed a HUGE performance increase from the server. The websites load faster, an area in which we’ve been targeting and trying to improve since the new rebuild of the sites. I may post a few examples to include LINQ in the future. Tags: LINQ ...
I was playing around with converting some HQL and Criteria queries to LINQ, and the result is pretty slick:All I had to do was reference NHibernate.Linq and I went from: public IList<Stay> GetCurrentStays() { string hql = @"FROM Stay WHERE CheckinDate <= :now AND (CheckoutDate IS NULL OR CheckoutDate >= :now)"; var query = getQuery(hql); query.SetDateTime("now", DateTime.Now); return query.List<Stay>(); } to: public IList<Stay> GetCurrentStays() { var query = from stay in ...
The people behind the NDepend software recently provided me with their latest version of NDepend to see what I thought. I initially ran the package over one of my recent projects and found that the reporting offered in the latest version of NDepend was infinitely better than the previous version (1.0) that I worked with. I found the reports that NDepend was offering would be most valuable while building my latest project. For this reason I started my latest project in a manner that would leave much ...
ASP.Net Listview is a Template Driven Grid control from Microsoft. It combines the features of DataGrid, GridView and Repeater. There is lot of web resources available about ListView. I had a scenario where the grid control has to act like an Excel control. Excel allows us to enter data in each of the cell. Then a submit button can be used to perform the Update or Delete operation on the Bulk. Referral Links: http://weblogs.asp.net/scot... ...
Authentication and authorization plays a key role in the web world. Going distributed makes information sharing healthier. But only if it's allowed for the know contact it will be healthy. We can very well see this in the existing web world. We have the memberships and roles for ASP.Net web applications. In addition we also have forms authentication and NTLM authentication. Going smart client is always best. But considering security it has to be more secure since smart clients attract all the people ...
I am just starting to work with LINQ to XML and tried to find child document similar to the following: xml.Element("client/child"); But it throw exception System.Xml.XmlException: The '/' character, hexadecimal value 0x2F, cannot be included in a name. The reason is that LINQ to XML doesn't directly support XPAth Fortunately there are extensions, that allow to use XPath for XElement search/selection. using System.Xml.XPath; and then var clients = xml.XPathSelectElements ( "client/child" ); Consider, ...
Decidí comenzar (y no serán raros los posts sobre programación) hablando de LINQ, que es un tema al que le había sacado la vuelta durante mucho tiempo porque me parecía algo complicado y no había visto la funcionalidad y valor agregado que nos ofrece a los desarrolladores. LINQ (Language Integrated Query) ofrece una especie de abstracción respecto a la fuente de datos de la que se obtiene la información y proporciona una estructura sintáctica consistente (similar al SQL) que se puede utilizar para ...
This is the second pilot podcast to accompany the fortnightly MSDN Flash newsletter (Check out Pilot Show 1) I am working through issues around getting the best quality for recording (both of myself and folks I interview), deciding which tools to use to process the raw audio, what show structure to use etc. Once I have it completely pinned down I will go live with the “real” podcast which you will be able to subscribe to using ITunes and similar and will be published every two weeks. In the meantime, ...
Long past due is a review of Julie’s book, Programming Entity Framework, ISBN 978-0-596-52028-1 Julie adopted Entity Framework early on, from before it was even available to most MVP’s. This book is a reflection of that involvement with the product and the product teams over the past few years. This 23 chapter, 750+ page book covers a lot of ground and provides a great reference book for almost everything entity framework related. The first few chapters introduce the framework and will give you a ...

So, in an attempt to extract digits out of a string of variable length, which technique is better?

This was primarily a test of the Enumerable.Range() method, but then turned into a refactoring question.

This, of course assumes Dot Net 3.5 (LINQ) is available:

Code showing two methods and a test method

 

Recently I have started playing with the Moq (pronounced "Mock-you" or just "Mock") a Mocking Library for .NET Developers, that takes full advantage of .NET 3.5 (i.e. Linq expression trees) and C# 3.0 features. Here in this post I will discuss how I have used the TryUpdateModel method in the Form POST scenario and also share how I have written a test case using Moq mocking library to deal with the TryUpdateModel<TModel>... model) method of the ASP.NET MVC controller. I have a very simple ...
I have started talking to developers about what they can expect in Entity Framework V2 such as in my session at DevWeek 2009 (Check out the slides and links). Folks have liked what they have heard and are keen to get more detail. The good news is the development team have been busy posting updated information this week (May 11th and 12th 2009) about what we can expect to see in .NET 4.0. Update on the Entity Framework in .NET 4 and Visual Studio 2010 “Since we shipped the .NET Framework 3.5 SP1 and ...
The Brandon .NET User Group will be hosting an event this Thursday, May 14th! From their website: In this session we will take you through building a data-driven web site using some of the latest tools in the ASP.NET landscape. We will go from zero to fully-capable site in 10 minutes, then drill deep to cover off how it all came together. Discussion: ASP.NET, LINQ to SQL, Dynamic Data Templates, URL Routing, SQL Server Express 2008 Pizza will be provided. To register for this event, click here ...
I installed SQL Server 2008 Reporting Services with Microsoft Dynamics AX 2009 Reporting Extensions on a 64-Bit Windows Server 2008 system. While Deploying the reports I encountered the following error message: ===========================... Error: Deployment failed unexpectedly with the message: Not found See the log file for further details. Deployment failed with the following exception: System.Management.Managemen... Not found at ...
I have a typed Dataset, generated by VS Designer. Resently I've added a new column to one of the tables, and suddently in different DLLs where the dataset was used, I've started to get Error 22 The type 'System.Data.TypedTableBase... is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.DataSetExtensi... Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934... Apparently VS 2008 changed the base class for Typed DataTables 3.5 : public ...
That’s right, I said it, I’ve been doing it, and I abso-effin-lutely love it. A few months ago my co-worker, Troy, posted a question on Stack Overflow. We were doing integration testing on a project we were working on, and as the object graph grew larger, the code required to test query logic became painful. Since I am a sissy and don’t like pain, Troy asked the question on SO about how we might do it less painfully, and we got this answer, and it totally changed our TDD/BDD lives. The answer came ...
When we use LINQ To SQL in C#, the compiler doesn't generate IL to implement our query - we want Sql Server to execute the query, and so IL would not be much good. Instead the compiler creates data that describes our query, in the form of a System.Linq.Expressions.Exp... When the query needs to be executed, LINQ To SQL examines the expression and converts it to the equivalent T-SQL, and sends that to the database for execution. It follows, then, that if we want to use LINQ To SQL in F#, we'd ...
Had a great time on Tuesday (5th May 2009) at NxtGenUG in Oxford. A very friendly crowd, a fun user group and great to watch the banter between Alex and Barry first hand, rather than over twitter :-) I also won a rubber duck – which justifies working in the evening in my book :-) Useful links: MSDN Flash eBook 13 of the “Best Technical Articles of 2008” (also http://bit.ly/flashebook1) MSDN Flash Podcast Pilot For feedback (also http://bit.ly/flashpod1) http://blogs.msdn.com/efdesign The Entity Framework ...
Here's a really short and simple bit of code that has the potential to be a bit of a time-saver. The FindControl method of the Control class is used to find a specific child control of a given parent, searching by ID. This method, however, doesn't search the control hierarchy recursively: it searches the direct children of the specified parent control only. While writing a recursive version of this method is trivial, a rather nice way to make the method reusable is to implement it as an extension ...