|
|
Using LINQ To Filter By Object Type and Then Quantify |
|
|
By Joe Rattz on
4/12/2010 4:48:28 PM
|
|
|
Using LINQ To Filter By Object Type and Then Quantify
Every so often I run across a case where LINQ comes in so handy that I just want to post a quick article sharing some particular usage of it. For this example I was working on a web page that shows user roles and their permissions within my applictation. Below is a photo showing how the display looked before my added LINQ code.

My web application has other roles not listed in that image. This is why there are some permissions that none of the listed roles are approved for such as "Allow Access To Site/User/Role Maintenance". For this page, I wanted to omit any rows from the display where at least one of the roles wasn't approved for it. After all, these permissions were irrelevant for these role ...
|
 |
|
Comments (1)
|
More...
|
|
|
Using LINQ With System.Web.Caching.Cache (A Legacy Collection) |
|
|
By Joe Rattz on
3/3/2010 5:49:05 PM
|
|
|
|
Using LINQ With System.Web.Caching.Cache (A Legacy Collection)
In my previous blog post titled "Creating A Reusable AdRotator ASP.NET User Control Using LINQ" I took advantage of caching with the System.Web.Caching.Cache object to prevent constantly querying the database for the ad content. Since I intentionally didn't leverage the cache dependencies feature, my cached ad content would only refresh at a certain time interval. After putting that code into production I realized what I really wanted was a way to manually flush the cache of the ad content when I wanted to. This would allow me to keep the ad content cached for a long period of time but provided a way to flush the ad content when I wanted it to change.
So I created a page to allow me to ...
|
 |
|
Comments (0)
|
More...
|
|
|
Creating A Reusable AdRotator ASP.NET User Control Using LINQ |
|
|
By Joe Rattz on
2/11/2010 11:07:33 PM
|
|
|
Creating A Reusable AdRotator ASP.NET User Control Using LINQ
I recently had the need for an AdRotator on one of my websites. ASP.NET already comes with an AdRotator server control but since I wanted to make it even easier to reuse, I decided to create an ASP.NET user control that leverages the ASP.NET AdRotator server control, but handles all the lower-level details.
Requirements
One of my requirements is that I wanted to be able to have multiple instances of this user control, perhaps even on the same page. I also wanted to be able to either have an instance have its own pool of ad content, or share the ad content with another instance. Since the built-in AdRotator control has a Keyword feature, that would be how I would control which pool of ad content an instance of the user control displayed content from.
Additionally, I wanted the ad content coming from the dat ...
|
 |
|
Comments (0)
|
More...
|
|
|
A Practical Lambda Expression Example For The UPS Tracking Web Service Call |
|
|
By Joe Rattz on
2/3/2010 3:17:28 PM
|
|
|
A Practical Lambda Expression Example For The UPS Tracking Web Service Call
In "Pro LINQ: Language Integrated Query in C# 2008" I provided an example of the evolution of named methods to anonymous methods and finally to lambda expressions. I was illustrating the brevity that anonymous methods provide over named methods, and that lambda expressions provide over anonymous methods. Just this week, while consuming the UPS Tracking web service, I have yet again found lambda expressions to be useful for this purpose.
When compiling the UPS-provided test code, I received the following warning:
'System.Net.ServicePointManager.CertificatePolicy' is obsolete: 'CertificatePolicy is obsoleted for this type, please use ServerCertificateValidationCallback instead.
While it's just a warning and the code worked just fine, the code causing the warning has been obsolete for quite a while now so I thought I ...
|
 |
|
Comments (0)
|
More...
|
|
|
Using LINQ to Generate Test Data with the Range Operator |
|
|
By Joe Rattz on
10/21/2009 12:27:41 PM
|
|
|
Using LINQ to Generate Test Data with the Range Operator
When working on Pro LINQ, one of the operators that caught my attention is the Range operator. The Range operator generates a sequence of integers. At the time, this seemed like it could be very useful for generating test data. I just used this again for a sample application I was working on and thought I should make a blog post about it.
int numItems = 200;
var list = Enumerable.Range(1, numItems) .Select(i => new &a ...
|
 |
|
Comments (0)
|
More...
|
|
|
|
|
Using LINQ to Obtain a Control Reference in an ASP.NET Repeater Item's ControlCollection |
|
|
By Joe Rattz on
1/23/2009 2:22:41 PM
|
|
|
|
I haven't been blogging about LINQ much, but I am making it a new year's resolution to blog more frequently about LINQ. Now, don't expect daily or even weekly blog posts because I am just not as prolific as some bloggers. I don't know how some bloggers do it. But, I do plan on blogging more frequently.
One of my favorite, but under-utilized, ASP.NET controls is the Repeater. I think it exemplifies what it is that we like so much about the web; that is, the graphic representation of data. Sure, I use web grids more frequently, but when you have multiple instances of data that just doesn't fit in a single line well, the Repeater is the answer. Consider listings of homes for sale, or cars. You typically see an image of the house or car, and several fields of information. There are usually so many fields, that the data will just not fit in a single line in a grid. Plus, the image would make the l ...
|
 |
|
Comments (2)
|
More...
|
|
|
LINQ to SQL Has a Future Despite the Rumors |
|
|
By Joe Rattz on
9/22/2008 10:15:51 AM
|
|
|
|
For the last several months, I have repeatedly heard a rumor that there was no future for LINQ to SQL. One reader even informed me that they heard LINQ to SQL was going to be snuffed and that because of this, their company changed architectural direction away from LINQ to SQL.
Concerned that the rumors may be either true and some developers are on a dead end path, or false and LINQ to SQL adoption may be suffering unnecessarily as a result of the rumors, I emailed Scott Guthrie at Microsoft to get his position on the future of LINQ to SQL.
Scott told me "Regarding LINQ to SQL, we definitely don't have plans to drop this. We plan to continue to fully support this going forward.".
Scott continued with "I actually blog most of my samples using LINQ to SQL these days (I just did one last week on ASP.NET MVC form scenarios and used LINQ to SQL for the data access). Expect to see me continue to blog mor ...
|
 |
|
Comments (0)
|
More...
|
|