“Contains” with LINQ to Entities

By James at April 22, 2011 21:40
Filed Under: Entity Framework

This post is mostly so I don’t forget, but if it helps you, then that’s groovy too.

In SQL you can use the IN clause to find a bunch of files where say the Id number is IN(1,2,3,4,5,6). However there isn’t that capability using LINQ to Entities.

I need this functionality for a project I’m working on and ran across some Bing results which gave me some ideas. Here’s how I did it.

 

var ressFileList = _db.RessFiles.AsEnumerable().Where(db => _ressFileIds.Contains(db.Id)).ToList<RessFile>();

 

Where _ressFileIds is a list I’ve generated elsewhere. The key is to use AsEnumerable() when calling the table you want to find the Id values in. Works like a champ.

James

Watch out! Visual Studio SP1 Pack for VS and VWD with WPI

By James at April 14, 2011 20:18
Filed Under: ASP.NET, Beta Software, Entity Framework, Miscellaneous, Technology in General

I like to have all my tools updated and current and wanted to install the RTM version of IIS 7.5 Express, SQL Server Compact 4.0 with the tools, and Web Deploy 2.0. I found a link to install these, along with Visual Studio 2010 SP1 via the Web Platform Installer. http://www.microsoft.com/web/gallery/install.aspx?appid=VWDorVS2010SP1Pack

Ok, methinks, I already installed VS 2010 SP1, so this should be smart enough to see this and not muck things up. Boy was I mistaken. After 90 minutes of installing, I figured something was wrong and cancelled the installation. Man, was that ever a bonehead move! My entire development environment got hosed; currently working solutions wouldn’t open, MVC 2/3 templates were gone, lots of frustration. Running SP1 again, I was given the opportunity to repair the installation, and that failed…twice.

I finally uninstalled VS 2010 SP1, uninstalled VS 2010, then reinstalled both. However, now this time, the Entity Framework templates were missing, and opening an EDMX file just showed the XML. Yikes.

I did another round of uninstall/reinstall, only to find out that both versions of MVC 2 and 3 didn’t have the tooling and my current MVC2 project doesn’t recognize any MVC related code.

I keep my VS 2010 .iso files on my server and use a virtual CD drive to run them. Doing a repair this way, caused a ton of problems too, as the VS 2010 installer wants to install .NET 4.0, which wants to reboot the system. Naturally when the system reboots, the installer wants to find the setup files, but since it takes time to find all the drives after a reboot, the install keeps failing.

What a waste of a day and a half.

Lessons learned

1. Don’t use the VS SP1 Pack for VS and VWD from the Web Platform Installer. Get the individual downloads for the apps you want to install (IIS 7.5, SSCE and Web Deploy 2.0) and run them by themselves.

2. Copy the files from the VS 2010 .iso to a local folder and run the setup from there. This way after a reboot, the installation will know where to look to continue on.

3. If it ain’t broke, don’t fix it.

Sigh….

Inland Empire .NET User’s Group–April 12, 2011–Brent Harris

By James at April 13, 2011 12:21
Filed Under:

Has someone ever handed you a database and asked you to find a problem and fix it?  Have you ever needed to step back into a database that you had not seen in years and try to fix a problem?  Where do you start looking when the territory is unfamiliar?  User Group member, Brent Harris gave a pleasing talk on “Data Mining in Unfamiliar Territory”, which including him actually mining for gems with a prop mine. Lots of fun.

Brent is a full time IT Customer Service Rep and Developer for Enerpath, a company that provides energy savings opportunities for homes and businesses across the nation.  In his spare time, Brent enjoys .NET programming, Runescape, and adventures with his family.

Attendance: 28

Raffle Prizes: 30

-James

INETA gets a new Board Member

By James at April 11, 2011 19:03
Filed Under: Life in General, community, evangelism, user groups, Technology in General

I’ve got news!

 

I’m honored and humbled to have been elected to the Board of Directors for the International .NET Association (INETA), where I will be in charge of handling the Marketing and Sponsorships for the group. We had our first semi-annual Board Meeting this past weekend (April 8th through 10th), with six new members, and there was a ton of passion and excitement for bringing INETA up to speed on visibility, supporting our user groups, bringing new user groups into the family, and keeping INETA viable and relevant. Plus I got to meet a bunch of really groovy people; the rest of the Directors and Officers:

 

Joe Guadagno, Dane Morgridge, Woody Woodruff, Robin Edwards, Chris Coneybeer, Mark Rowe, Lori McKinney, Steve Bohlen, Nancy Mesquita and Stacey McKown.

 

It will be lots of work, but I am thrilled to be given a chance to be part of this. Stay tuned for updates and more information. And, don’t forget to checkout the INETA site at www.ineta.org!

 

James

About the author

James James is a five time and current Microsoft MVP in Client App Development, a Telerik Insider, a past Director on the INETA North America Board, a husband and dad, and has been developing software since the early days of Laser Discs and HyperCard stacks. As the Founder and President of the Inland Empire .NET User's Group, he has fondly watched it grow from a twice-a-month, early Saturday morning group of five in 2003, to a robust and rambunctious gathering of all types and sizes of .NET developers.

James loves to dig deep into the latest cutting edge technologies - sometimes with spectacular disasters - and spread the word about the latest and greatest bits, getting people excited about developing web sites and applications on the .NET platform, and using the best tools for the job. He tries to blog as often as he can, but usually gets distracted by EF, LINQ, MVC, ASP, SQL, XML, and most other types of acronyms. To keep calm James plays a mean Djembe and tries to practice his violin. You can follow him on twitter at @latringo.

And as usual, the comments, suggestions, writings and rants are my own, and really shouldn't reflect the opinions of my employer. That is, unless it really does.

James Twitter Feed

Recent Comments

Comment RSS

Month List