Friday, August 2, 2013

SignalR and WCF Custom TraceListener Integration

SignalR – recently created a demo application on this. Cool new technology from Microsoft again for  a "real web" experience.

WCF custom TraceListener – created a demo application – custom trace listener on top of a WCF service, hooked it up with SignalR. Now my clients can open a web page and can view what their services are working on....


#trivedimehulk@gmail.com

Tuesday, March 12, 2013

Entity Framework Wrappers – Part 2 – AppFabric and “effective caching” with EF integration aka “second level caching with EF” – simplified!

Entity Framework Wrappers – Part 2 – AppFabric and "effective caching" with EF integration aka "second level caching with EF" – simplified!

Problem statement: I want my SQL data to be cached in a way where my EF calls still work seamlessly without doing any major code change but the data is retrieved either from SQL store or a cache store if it's cached already. Also if the data is updated in my DAL layer using EF context.save() methods, it should invalidate the cache store automatically for that entity.

Solution: Use EF wrappers "http://efwrappers.codeplex.com/" and use caching provider toolkit

Rough diagram for understanding how it works (before/after):

Before:



After:




Description:
The way it works is every simple. With EF wrappers we get to create a new entity connection in the extended object context class. The new improved entity connection executes the T-SQL query generated by LINQ TO ENTITIES code against either the SQL store OR the app fabric.
For SQL store to understand the t-sql query is fine but for appfabric (or any other cache store) cannot understand the t-sql lingo :) ??? 

Bingo! The EF caching wrapper classes [EFCachingCommand.cs] creates the required methods for executing DB readers etc and before going to SQL store a small code snippet like below is injected :) which checks if the cache is already having the required result set OR entity object or anything :)

Required components:
Windows App Fabric Server (installed, configured and running) OR Azure [I haven't tried with azure yet]
VS 2010 or above
A SQL database

Reference material:
A working solution attached in zip file:Link


Tuesday, March 5, 2013

Entity Framework Provider Wrappers - trap the monster!

Entity Framework Provider Wrappers

I want to know what my entity framework code is executing under the hood?

I want to trap the SQL code entity framework is sending to my sql server and wants to inject something?

I want to profile my entity framework object context sql calls?

Answers to all above questions: http://efwrappers.codeplex.com/

A very good handful set of provider wrappers provided by Microsoft which you can plug in and start trapping EF.

I crated my own version which works as a service, provides a trappable entity framework connection to any remote client. J

#trivedimehulk@gmai.com

Monday, January 21, 2013

How do i quickly find and attach the w3wp if i am running multiple sites?

All folks who work on VS and ASP.NET and work on multiple web projects/websites finds its very tedious to find and attach the right solution to right application pool. Go to command prompt, find application pool ID, go to debug -> attach process and attach it…..grrrrrrrrr!

I wrote a small macro which you can put in your macros and give it a short cut and will be really quick to do above of all and attach w3wp easily with 3 keyboard clicks.

=++++++++++++++++++ code snippet
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Windows.Forms
'Author: Mehul T - 1/12/2012
Public Module AcmeAttachProcessMacro

    Public Sub AcmeAttachProcess()
        Try
            Dim process = New System.Diagnostics.Process()
            process.StartInfo.FileName = "C:\Windows\system32\inetsrv\appcmd.exe"
            process.StartInfo.Arguments = "list wp"
            process.StartInfo.UseShellExecute = False
            process.StartInfo.CreateNoWindow = True
            process.StartInfo.RedirectStandardOutput = True
            process.Start()
            Dim output As String = process.StandardOutput.ReadToEnd()
            process.WaitForExit()
            Dim PID As String = InputBox(output, "Enter process ID from following list:")
            If PID.Length > 0 Then
                Dim Processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses
                For Each processEach In Processes
                    If (processEach.ProcessID = Int32.Parse(PID)) Then
                        processEach.Attach()
                    End If
                Next
            End If
        Catch ex As Exception
            MessageBox.Show("Error:" + ex.Message)
        End Try
    End Sub
End Module

++================================

#trivedimehulk@gmail.com