Saturday, June 30, 2012

.Skip() and .Take() in C#'s LINQ seem made for paginated lists.

Johnny, Sid, Paul, and Steve were the names of the four guys ... on Twitpic

The test below (which passes and was inspired by page 374 of C# 4.0 in a Nutshell) shows first how a query brings back four contacts and then how a second query brings back the two contacts in the middle of the four by skipping the first record and taking the next two. A tiny record set like this is hardly worthy of pagination, but I'm sure that you can see how IQueryable and LINQ may work well with paginated lists by utilizing Skip and Take.

using System.Collections.Generic;
using System.Data.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Whatever.Models;
using System.Linq;
namespace Whatever.Tests
{
   [TestClass]
   public class IQueryableTest
   {
      [TestMethod]
      public void DataTest()
      {
         string Ok = @"server=.\sqlexpress;database=OK;Integrated Security=true;";
         DataContext dataContext = new DataContext(Ok);
         Table<Contact> contacts = dataContext.GetTable<Contact>();
         IQueryable<Contact> query = contacts.OrderBy(c => c.City);
         List<Contact> list = query.ToList();
         Assert.AreEqual(list.Count(), 4);
         Assert.AreEqual(list[0].Name, "Johnny");
         Assert.AreEqual(list[1].Name, "Sid");
         Assert.AreEqual(list[2].Name, "Paul");
         Assert.AreEqual(list[3].Name, "Steve");
         query = contacts.OrderBy(c => c.City).Skip(1).Take(2);
         list = query.ToList();
         Assert.AreEqual(list.Count(), 2);
         Assert.AreEqual(list[0].Name, "Sid");
         Assert.AreEqual(list[1].Name, "Paul");
      }
   }
}

append to the html inside of a div with jQuery

$('#Tweets').items.join(''));...is part o... on Twitpic

 
 

Addendum 6/5/2014: $('#MyDiv').append('my copy'); ...is an example of appending. I sure was lazy when I made this post.

Friday, June 29, 2012

IIS7 notes

  1. In the application pools in IIS7:
    1. Managed Pipeline Mode
      1. Classic Mode emulates IIS6
      2. Integrated Security is new and can, among other things, block random .html or .txt or .jpg files from being seen if a user is not permissioned.
    2. Identity (can define what user one connects to a database as)
  2. http://blog.dczweb.net/post/Migration-of-ASPNET-app-from-IIS6-to-IIS7-(75).aspx touches on upgrading ASP.NET apps from those which run on IIS6 to those which run on IIS7:
    1. system.web will be in Web.config in IIS6
    2. system.webServer will be in Web.config in IIS7

Paul Hammant's Next Generation UI technologies presentation!

See http://www.youtube.com/watch?v=Qo0XCz-neNs&feature=youtu.be

get the Mongo .dll

Install-Package mongocsharpdriver installs the Mongo .dll for ASP.NET via NuGet.

Right-click on the desktop in Windows 7 and type the first letter of the file you want to find.

Type the letter over and over again. The selected file will tab from file to file where each file starts with the applicable letter. You'll find what you are looking for soon!

One may view the HTML source of emails in Microsoft Outlook 2010.

This feature which used to exist in Outlook Express while being left out of Outlook itself, has been incorporated!

  1. Open an email and pick "Actions" from the "Message" tab.
  2. Pick "Other Actions" from the "Actions" menu.
  3. Pick "View Source" from the "Other Actions" menu.