Tag | LINQ Posts

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 ...
If you are using a template document and replacing text programmatically using the Office Open XML SDK 2 API you will need a way to identify the target to be replaced. One option is to use a Content Control and setting the tag value the same for all of the controls that need to be substituted with a single value. After some trial and error and a lot of digging through the DocumentReflector I came up with the following LINQ query to get a list of all blocks with the same tag name. var blocks = from ...
In this Issue: Damian Schenkelman, Jonathan van de Veen, Stephen Forte, Laurent Duveau(2), Alan Mendelevich, and nmarun. From SilverlightCream.com: Why Silverlight 3 Navigation cannot be fully leveraged when loading modules remotely with Prism 2 Damian Schenkelman goes into the future [November 5 :) ] to discuss why there are issues with Silverlight Navigation in Prism. He references articles that contain workarounds as well. Connecting to the SqlMembership model through Silverlight and WCF Jonathan ...
How time flies! Monthly Guild meetings, several code camps, an MVP Summit and oh yeah, that mobility app we did at work. We consumed 2008 and much of 2009 working with Microsoft on a serious development effort using Visual Studio 2008, SQL Server 2008, Sync Framework, SQL Server CE, Windows Mobile 6, Vista, Windows Server 2008, Windows Communication Framework, Windows Workflow, LINQ – have I left anything out? Learning our application requirements put Microsoft and the end of the fire hose for a ...
While I was planning to write about the same topic and have the draft ready in my Windows Live Writer waiting to complete, I found an interesting question in StackOVerflow and couldn’t just resist to answer: ORM/Persistence layer Advice The question starts with: I'm starting a new project and I'm looking around for either a very good ORM or for a non-SQL-based persistence layer. Then follows up with a REALLY GOOD summary of what he believes about each known ORM he knew out of his own findings and ...
I will use the AdventureWorks database to demonstrate how to perform CRUD operations using LINQ. You can use LINQPad (a free tool) to execute your C# statements without going through the hassle of writing a program using Visual Studio 2008. Launch LINQPad, add your SQL Server Connection and select AdventureWorks as the Database. Remember to select C# Statement(s) as the Language Type. Create Record 1: Department newDept = new Department()2: {3: Name = "Consulting",4: GroupName = "Consulting",5: ModifiedDate ...
Sometimes a LINQ query or other method returns a nested collection but you just want one big collection instead. SelectMany is the answer, see the code below. It can off course also be combined with OrderBy or Distinct if you prefer. List<List<double>> nestedList = new List<List<double>> { new List<double> { 1.2, 2.4 }, new List<double> { 3.6, 4.8 } }; List<double> flatList = nestedList.SelectMany(doubl... => doubleList).ToList(); foreach (double item ...
When passwords are set to expire after a certain number of days in Active Directory, the remote users suffer because they do not get a notification like the local users do that their password is going to expire. Eventually, it becomes too late for them to change their passwords and they get locked out. I found this out recently and did not believe that there was no built in support for this. I started researching and indeed, there was no built in support. The solution was to email the users, either ...
I don’t know why it never occurred to me to try this, but I wanted to write this quick post regarding this little tidbit of information because others might have been wondering the same thing as me. I described how I use paging using the ObjectDataSource and LINQ on this post: http://geekswithblogs.net/s... So what if you want to page some data that also includes extra parameters? For example, lets say I have a web app that ...
Back Links LINQ Overview, part zero LINQ Overview, part one (Extension Methods) LINQ Overview, part two (Lambda Expressions) Note: I realize it has been a really long time since I've posted anything. It is both exciting and humbling that I continue to receive such positive feedback on these articles. In fact, that is why I am trying to put in the effort and finish off this series before moving on to more recent topics. This nomad has been on some interesting journeys these past months, and I am really ...
It has been a while since I published my last article on my blog. Now I`m back hoping to deliver you interesting stuff about advanced methods in LINQ. First article describes the most complex overload of GroupBy method in little details and is available here [DIRECT LINK]. The second one - which will be published soon - shall describe GroupJoin method.
WCF REST Starter Kit Preview 2 contains not only tools for creating REST services. It include rich set of client tools, that allow to do HTTP-requests and process service response in more convenient way. I create small overview of it basic features. We’ll create a simple WPF desktop client for Yahoo Shopping Web Services. Our client sill search products by the keyword. Details of Search API is available here, but information about GET-request format and service URI is enough. For example, if we want ...
At the start of 2009 we worked with InnerWorkings to help over 7000 UK developers get access to free training in C# or VB. As there are at least 100,000 UK developers (depends who you ask), we decided to again partner with InnerWorkings to bring you free training in WPF, Silverlight and .NET Framework 3.5 SP1. I am a big fan of the InnerWorkings approach which embeds a set of programming challenges into the Visual Studio IDE. Maybe not for everyone but certainly is an interesting and engaging alternative. ...
Today I got the following error when working with the Linq to Sql dbml file: "System.InvalidOperationExc... Incorrect AutoSync specification for member 'xxxxx'." The problem involved the primary key "NationId" in the following image: When you right-click on NationId and select properties, you see this in the Properties window: The problem is that the auto-sync property should be "OnInsert" instead of "Always". However, I have not figured out how to make "OnInsert" the default when the view/table ...
The Beta 2 version of DPE’s Visual Studio 2010 Training Kit is now live (you can find it at http://tinyurl.com/Beta2Tra... A training kit includes presentations, hands-on labs, and demos. This content is designed to help you learn how to utilize a variety of Visual Studio 2010 and .NET Framework 4 technologies. The Beta 2 release of the Training Kit contains 15 presentations, 19 hands-on labs, and 13 demos. Many technologies are covered in this release, including: C# 4, VB 10, F#, Parallel Extensions, ...
Day 1 of the Microsoft SharePoint Conference 2009 is almost over. The conference is impressive. There are over 7400 people in attendance, a number that represents 92% growth over last year and which tops this year’s Tech*Ed and MIX attendance combined. All this in a year when most events’ attendance is way down. That should tell you something about SharePoint, and should explain why Steve Ballmer, in his keynote at the conference this morning, said (1) he wasn’t going to start this keynote by talking ...
Thanks to everyone who attended my presentation “Deconstructing an ASP.NET MVC Website” at the Carolina Code Camp on Saturday, October 10, 2009. I really enjoyed sharing some of the things I learned while building my first ASP.NET MVC website. As promised, I am posing my slide deck and resource links below. Slide Deck ASP.NET MVC Free ASP.NET MVC Tutorial Free Microsoft Virtual PC VHDs Microsoft Web Platform Installer LINQ to SQL – Many-to-Many Relationships Part I LINQ to SQL – Many-to-Many Relationships ...
It’s been a while since I’ve blogged since things have been crazy busy. I finally decided to kick myself and do a post so without further ado, the problem at hand: A co-worker of mine asked me whether its possible to dynamically create a type from some data he is receiving from a WCF service (over HTTP). My natural response was, why would you need to do that since Visual Studio creates a proxy from the metadata exposed by the service and the return types would typically be DataContracts. Well, it ...
So I scraped together the money and paid in full to go to the conference as I've said before. Here is a complete list of all the sessions I will be attending: Monday 1:15 - Overview and Whats New for SharePoint 2010 IT Pro's 2:45 - What's New in Office 2010 for Developers 4:30 - Web Content Management in SharePoint 2010 Tuesday 9:00 - Building Rich Internet Applications with Silverlight 3 and SharePoint 2010 10:30 - FAST Search for SharePoint: Capabilities and Deep Dive 1:15 - Developing SharePoint ...
UPDATE: Please see first comment to do this the "safe" way... It took a bit for me to get comfortable enough with LINQ-to-objects to write ‘queries’ off the top of my head…but once you’re used to it you realize it’s much more concise, easier to interpret/read, and well..it’s less code. Here are some real quick examples… This first example selects the string array value as well as its position from the someItems array. Note, the user of new{} creates a new generic type that has the properties ItemName ...
Static Reflection in .Net Where have I been? I recently took a few minutes to look through the latest MSDN magazine and ran across a nice article by Jeremy Miller on “Functional Programming for Everyday .NET Development”. The section titled “Lambdas as Data” was my first introduction to static reflection in .Net. Where the heck have I been? I don’t write database persistence code, so I am not familiar with NHibernate (or fluent NHibernate) (which is where Jeremy’s sample comes from), but I am still ...
I am working with Entity Framework as model in a REST service, using the CollectionService<T> and i found a little issue in the behavior of Linq to Entities,this is well know but i hope a change in .Net 4.0 Currently Linq to Entities not supports projections that returns types with parameterized constructors, by instance for a method that return a IEnumerable<KeyValuePair... Course>> i wanna make 1: .Select(c => new KeyValuePair<string, CustomType>(c.StringProp... ...
Recently I had the need to implement support for Dynamic Linq queries in my framework project. For the uninitiated, Dynamic Linq allows me to write statements like this: var query = db.Customers.Where("City == @0 and Orders.Count >= @1", "London", 10). OrderBy("CompanyName"). Select("New(CompanyName as Name, Phone)"); where I can specify the predicates and selectors as string values. Microsoft has published a helper class that enables DynamicLinq support here -->C# Dynamic Query Library (included ...
.NET University has a variety of presentations available for download, including code examples and videos. Use the materials to learn or to present at your next DNUG meeting ;) The presentations cover a variety of different topics, so if you’ve already got a presentation planned and you just want to compare, be sure to check’em out. All the popular topics like Silverlight, WPF, WCF, LINQ, and ASP.NET MVC are covered. Instant presentations, just add presenter. http://www.dotnet-u.com Technorati Tags: ...
I've been meaning to post this for a while, but I have some upcoming speaking engagements coming up throughout South Florida. Yesterday I was in Naples, Florida speaking at the SW Florida .NET Code Camp, speaking on a lot of the new things coming in ADO.NET 4.0 Entity Framework (obviously ). I completely ran out of time as I tried to cram a bunch of topics into an hour. I talked about Model-First development, POCO, and T4 templates. I first gave a brief EF introduction to those who were new to EF, ...
Based on a few examples i found when googling the web, i made a class that can help you query excel sheets in a very simple way with plain vanilla .NET code. Our example file contains one sheet with the name "Sheet1", listing a few employees. Id FirstName LastName Age 1 John Doe 35 2 Bob Smith 42 3 Charlie Smith 40 4 Steve Rights 29 5 Bill Abrams 24 Now lets say that you would like to read all employees from this sheet into an anonymous type list and order the result by age. The following console-application ...
Today I took on the challenge of improving the performance of a set of repository retrieval methods that have been a bottleneck for our system for the past week. Here were the requirements and details for the most challenging method: There is a Clinic and a Service table with a joining table for the many-to-many relationship, ClinicService. A clinic provides one to many services and a service can be provided by one to many clinics. The method accepts in a list of primary key integer values for the ...
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 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-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; ...
I've been trying to sharpen my blunt mathematical brain by solving some of the problems on Project Euler. Prime numbers figure in a few of the questions, so here's a bit of C#/LINQ goodness for generating them up to 100: Enumerable.Range(2, 100 - 2).Where(i => Enumerable.Range(2, (int)Math.Sqrt(i)).All((j) => i == 2 || i % j != 0)).ToList().ForEach(Consol... ...
in·ane (in-an') adj. in·an·er, in·an·est One that lacks sense or substance. The American Heritage® Dictionary of the English Language, Fourth Edition Copyright © 2009 by Houghton Mifflin Company. Published by Houghton Mifflin Company. All rights reserved. One of the first signs that code needs to be refactored is that it looks complex. Complex solutions are rather easy to come by, but are far less maintainable than their harder to write, easier to read brethren. Like any well-crafted sculpture, it ...
At first sight, StreamInsight doesn’t appear to offer any support for dynamic queries. Once you have got over the initial ‘wow’ factor of creating continuous queries over streams using LINQ, rather than some SQL dialect or specialised DSL, the reality hits you that your query is just code. You wrote the LINQ using C# or VB.NET, and you ended up compiling it into some assembly. That’s all very well, but it’s not very flexible. How are you going to store and manage your queries in a repository so that ...
Unlike WPF, Silverlight doesn't contain a DataTemplateSelector. A DataTemplateSelector is used to select a data template based on the data-bound element and the data object. But, it isn't hard to build your own. Start by adding a class to the solution and call it something like “DataTemplateSelector”. Inherit this class from System.Windows.Controls.Con... The ContentControl class has a property for a data template and a property for content, which you can use to data-bind to. Next, create ...
This is one of a series of posts on my preparations for sessions on Azure and ORMs at Software Architect 2009. The plan vs actual for day five (The last day): Play, play, play with the technology. PART DONE Produce outline skeleton demo sequence for both sessions PART DONE Produce a backup VM “just in case” :) DONE Run through both presentations for rough timing (mainly to figure out talk to demo ratio) PART DONE Look into this annoying bug which appeared to have started after I installed Silverlight ...
Problem Statement: To Evaluate a complex expression in dotnet and show the result to end users. The expression could be something like this X2 +Y3+Log10 (z) . Solution: There are different ways to solve the problem stated above. Am planning to show how to use Scripting Engines like Jscript/VBScript inside C#. We can make use of Windows Script Control to achieve this. Windows Script control can be downloaded from MSDN site. It is shipped as an Activex control which lets you make use of JavaScript ...
C# in Depth is not for beginners. It assumes a working knowledge of C# 1.0, and is not so much a tutorial of C# 2 and 3 features as an in-depth examination of how and why they work. I don’t think I learned anything I didn’t know about using generics, extension methods, delegates, anonymous methods and lambdas, but Skeet does a great job of zooming in on the inner workings of each of these features, building up to the big picture of how they all snap together to make the game-changing programming ...
Cet article concerne Visual Studio 2010 Beta1. Les informations peuvent ne pas être véritables lors de la sortie de la version finale du produit. La procédure suivante permet de créer un workflow simple et de le déployer dans IIS 7. Créer un nouveau projet dans VS 2010 : File | New | Project… Créer un projet de type Declarative Flowchart Service Library : Un projet de service sera alors créé possédant un nouveau service Service1.xamlx. (Normalement, dans les versions ultérieures, il ne devrait plus ...
Lambda expressions are yet another one of those things that took me a while to really embrace/ understand but once I did, I use them exclusively in LINQ. The reason it took me a while to finally start using them is because every time I tried to read an explanation of them, the author got bogged down in a ridiculous amount of details and explanations that I either got lost, or just lost interest. Once I learned how to use them, I found it was easier to go back and re-read those explanations and understand ...
This is one of a series of posts on my preparations for sessions on Azure and ORMs at Software Architect 2009. The plan for day three: Nearly got it all done. However I ended up spending more time on EF4 than I had planned as … there is a lot of it! Gather up good posts and samples for EF 4 (will likely blog this out) DONE Play with EF 4 as much as my day allows DONE Revisit EF 4 deck post play DONE And a late night re-read of the three Azure storage documents from way back (will add links in the ...
This is one of a series of posts on my preparations for sessions on Azure and ORMs at Software Architect 2009. [Initual release 22nd Sept 2009] [Updated 23rd Sept, with links from Julie Lerman] [Updated 2nd Oct, with slidedeck section] [Large Update 15th Dec – including PDC09 content, my new posts and plenty of stuff from Julie L, Tony and others] This is my attempt to pull together all (ok – most) of the improvements in Entity Framework 4.0 and aggregate useful resources against each. It is very ...
Got bit by a bug caused by me trying to do stuff smartly in Linq. Gentle reminder that Linq expressions are always recalculated. The bit of code is the following: public static void AddKnownTypes(IEnumerable&l... knownTypes) { // We only want to collect types that are new (hasn't been registered yet) IEnumerable<Type> newTypes = knownTypes.Where(t => !_knownTypes.Contains(t)); _knownTypes.AddRange(newTyp... // Fill in a dictionary of these newly added types foreach (Type type in ...
ASP.NET MVC Reports in ASP.NET MVC Integrating OpenID in an ASP.NET MVC Application using DotNetOpenAuth Microsoft Chart Controls to PDF with iTextSharp and ASP.NET MVC Setting Up ASP.NET MVC with NUnit for Visual Studio 2008 Standard Edition ASP.NET MVC ExtJS using LINQ Using ExtJS Grid with ASP.NET Ajax WCF WebServices & C# How To Get Started With Selenium Core And ASP.NET MVC ASP.NET MVC Cheat Sheets ASP.NET How to Implement Trackback Handler in ASP.NET How to Implement Pingback Handler in ...
I’m trying to be a better developer, so I try to make sure I follow best practices as much as I can. At times when I’m just creating simple methods though, every now and then I get somewhat hung up as to what do I use as types for my input parameters and return values. You see, it is something that is so basic, we create methods all the time, but most of the time, we don’t pay much attention to it since we’d just like to continue on with the task at hand. So I’m writing this to remind myself that ...
I tend to always have side projects going on. I think many developers are like this, either because we want to learn new things or have the opportunity to work on things that directly interest us or to make a little extra cash. Two of my side projects are the Pathfinder Project and Zombie Apocalypse. Pathfinder Project There are two kinds of companies in the world: the ones that listen to what consumers want and give it to them, and the ones that shove what they want to give you down your thoat and ...
I am visiting beautiful city of Nashvillie, TN, US and involoved in rather interesting project involving WCF, silverlight and SQL server 2008. Also being used are Search server (FAST) / Lucene .Net Omniture (for Web analytics) Integration with Community server, Twitter, Facebook Velocity – Distributed caching. MemCache – Web server Cache I am also planning to use Nikhil’s MVVM Silverlight Fx at silverlight end or MEF LINQ / Enity framework - for ORM. That remind me of scenario where i had to register ...
This weekend i was engaged with a rather uninteresting conversation with my wife. My wife is computer savvy but still is catching up on new technologies. Below is a brief snippet. I am hopeful that this will give you some idea on SAAS. Me: ok... Wife: What? you said something? me: Nothing. I was just talking aloud... its about SAAS. Wife: SAAS??? (for the less informed.. SAAS means mother-in-law in hindi !!!). Are you watching those hindi serials lately? me: Well, SAAS is a Acronym for Software As ...
One of my colleague remarked that LINQ is "VERY SIMILAR" to TSQL. However, he also cursed that why the LINQ guys have implemented it "reversely". What he meant that why the Select is reversed… SQL query will be 1: Select Name from Employee where sal > 80000 LINQ 1: var q = from emp in Employee 2: where emp.sal > 80000 3: Select emp; I cant help but giving him references to Korth & Sudarshan and mathematical Projections… That also reminded me of taking a quick tour of algebra which i am ...
Dependency properties is one concept which i always marvel. As programmer / developer i always like the concept, as by just introducing DP, so many stuff now is so easy(Read Template programming in XAML). DP is called a BEAST (in Silverlight and WPF) for reasons of complexity involved in understanding them. Also, of course, because they are so powerful language paradigm. I sometimes do think DP did not actually got their due. I mean, so many efforts is gone into explaining Lambda expressions, LINQ, ...
Well, here we are again. Last time, we talked about project structure and came up with the one we’ll use for this series. Next we’ll talk tools. We’ll talk tools like Tim Taylor talks tools: with lots of grunts for my favorites and only a little explanation about what the tools do.) This is mostly because there is LOTS of material on the interwebs about all of these tools. I tend to favor the tools that are the most widely used for two main reasons: they have been battle tested by the largest crowd ...
Just a quick tip that I found handy while doing some writing yesterday; chances are if you’ve played with LINQ you probably wrote something like this… var outputString = from s in inputString where s.Length > 1 select s; //Do some stuff with outputString in your method... Code like the above will work perfectly well if what you’re going to work with your implicit variable, outputString, within the body of the same method. But, as it stands, you can’t return outputString, or any implicit variable ...