Query for Entity Framework using Concept of Projection for Tuned Performance.

Hi Kids,

You should not filter your entity framework results with-in a loop.

It is better to code it like this.

var object = await db.Tables.Include(o => o.AnotherTable)
.Where(s => s.Created >= startDate && s.Created <= endDate)
.OrderByDescending(lambda => lambda.id)
.Select(anotherlambda => new TemporaryObject{
                        SelectedColumn = so.SelectedColumn ,

Do I have to tell you everything?

Asp.Net Identity IsInRole not working or Returning Empty

Hi Kids,

If this piece of code in Asp.Net MVC 5 on .Net 4.6 is Not working


Just code it like this.

       ApplicationUser u = await UserManager.FindByNameAsync(username);
       var roles = u.Roles;
       List<string> s = new List<string>();
       foreach (var i in roles)
           var r = db.Roles.SingleOrDefault(w => w.Id == i.RoleId);

       if (s.Contains("Admin"))
          return RedirectToAction("Index","Jumpers");

It will save you time.

Alright Kids! You’re Welcome!

Screen Scrolling with Mouse Wheel in Jquery

Hi Kids!

Here is how to detect scroll with Mouse Wheel in Jquery

$('#div1, #div2, #div3').on('DOMMouseScroll mousewheel', function (e) {            
            if(e.originalEvent.wheelDelta < 0) {

Alright Kids!

Simple Templating in C#

Hi Kids!

Here is a simple templating Sample and replacing placeholders in C#

StringBuilder str = new StringBuilder();          
string temp = "";

foreach (Item item in items)
     temp = Template.Text;    
     StringBuilder strTemplace = new StringBuilder(temp);
     strTemplace.Replace("{title}", item.title);
     strTemplace.Replace("{url}", item.url);
     strTemplace.Replace("{location}", item.location);
     strTemplace.Replace("{company}", item.company);                

Alright Kids!

How to love C# and Entity Framework

This is how to fall in love with Entity Framework Kids.

 [RegularExpression(@"^[A-Z]+[a-zA-Z''-'\s]*$", ErrorMessage = "Invalid Characters")]
 [Display(Name = "Firstname")]
 public string FirstName { get; set; }

 [RegularExpression(@"^[A-Z]+[a-zA-Z''-'\s]*$", ErrorMessage = "Invalid Characters")]
 [Display(Name = "Lastname")]
 public string LastName { get; set; }

How can anyone not love that piece of art Kids.
It’s a thing of beauty.

Creating Simple Serial Number in C# and Entity Framework

Hi Kids,

If you want to create a simple serial generator with prepended Characters in C#, here is how you do it Kids.

    var guestCode = "SERIAL00000000";
    // coming from newly created database entry from using Entity Framework
    var customerNumber = guest.id.ToString();
    // this code is self explainatory or do I have to explain it for you? c'mon...
    guestCode = guestCode.Remove(guestCode.Length - customerNumber.Length);
    // you know what's going on right?
    guest.GuestNumber = guestCode + customerNumber.ToString();

   // then apply the update to database using the db Context
    db.Entry(guest).State = EntityState.Modified;

Ciao Kids!

The best and Proper Way to code in Javascript is not to use Globals

Hi Kids,

You must avoid using globals in Javacript, its because
They are slower to look up than local variables and will clutter up the global namespace as well.

So here take a look kids. This is how you do it properly. 🙂

      var createObject = function(){
            var count = 0;
            var todo1 = function(){
                count += 1;

            var todo2 = function(){
                count += 2;

            return {
                task1: todo1,
                task2: todo2

      var obj = createObject();

Alright Kids! Ciao!