I wasn’t finding much with a quick search for enterprise library table value parameters or data access application block table value parameters. After a bit of research I discovered that versions <= 4.1 don't support tvps as well as I'd hoped. The key is you must cast (or create) a SqlDatabase and use SqlDbType.Structured. This will break your database independent code. The easiest way I see to use table parameters is create a DataTable and add columns to match the parameter. The column names of this table do not matter.

            DataTable table = new DataTable();
            table.Columns.Add(new DataColumn("ID", typeof(int)));
            table.Columns.Add(new DataColumn("Value", typeof(int)));
            table.Rows.Add(new object[] { ID, value });
 
            SqlDatabase database = (SqlDatabase)DatabaseFactory.CreateDatabase("DatabaseName");
            DbCommand dbCommand = database.GetStoredProcCommand("[StoredProcName]");
            database.AddInParameter(dbCommand, "@MyTableValueParameter", SqlDbType.Structured, table);
            using (IDataReader reader = database.ExecuteReader(dbCommand))
            ...

Tags: ,

I ran across a color chart for the named colors the other day while searching for something wpf related. It took me too long to find it today. The next time I’m digging around in my xaml for a background color and see BlanchedAlmond I’ll have a reference.

Wpf Silverlight System Color Chart Table

Wpf Silverlight System Color Chart Table

from:

http://msdn.microsoft.com/en-us/library/system.windows.media.solidcolorbrush.color(VS.95).aspx

Lately I’ve been playing around with Asp.Net Mvc. I’m trying to adapt the NerdDinner sample for a project I’m working on. The sample includes a class called PaginatedList<T>.  PaginatedList<T> looks something like this:

   public class PaginatedList<T> : List<T>
   {
        public int PageIndex  { get; private set; }
        public int PageSize   { get; private set; }
        public int TotalCount { get; private set; }
        public int TotalPages { get; private set; }
   }

My controller method looks something like this:

   public ActionResult FindBusinessesByName(string businessName, int limit, int page)
   {
      BusinessRepository repository = new BusinessRepository();
      PaginatedList<Business> paginatedBusinesses = new PaginatedList<Business>(repository.FindBusinessesByName(businessName), page, limit);
      return Json(paginatedBusinesses);
   }

I’m using jQuery to get a PaginatedList of businesses from my controller. I use the list of businesses to create an unordered list to display the business information. I haven’t played with jQuery or json serialization much so I was surprised to see that only the business data was returned. The extra properties on the PaginatedList were not. I dug around a bit and downloaded the newly released source for Mvc (woot!). I found the two lines in JsonResult.cs that do the serialization:
Read the rest of this entry »

I’m trying to generate  a view for Asp.Net MVC 1.0 using an Entity Framework model. This is from Details.tt.  Anyone seen this error?

I get this the first time I try to generate:

error CS0234: Compiling transformation: The type or namespace name ‘Data’ does not exist in the namespace ‘System’ (are you missing an assembly reference?)

Read the rest of this entry »