Redis as a cache server

Although Redis is much more than a cache, But it's possible to use as cache server specially in distributed applications. Redis lets you operate on the values and it's just a key value pair in memory database.

To getting start, get the latest version of Redis from here and install in your  windows machine (Server) by instruction and run it in your services. Redis runs in your server machine (you can have redis server and client in one machine which could be you client development machine) and you call it from client by a library... Continue

Introducing sqlbulktools

In my previews blog post I wrote about Z.bulkOperation. I migrated to sqlbulktools just because it's free with the same ability!(to be frank). Now to see the reason of my migration, fire up visual studio and Install the latest version of the library using the following command in console package manager:

Install-Package sqlbulktools

And get started!

  1.  static void Main(string[] args)
  2.         {
  3.  
  4.           &nb... Continue

Introducing Z.bulkOperation

Today I was tackling with a problem. It was about inserting and updating 200000 records of data. I just wanted to find a solution rather than writing Store Procedure. I just searched on the web and found a library named Z.BulkOperation

I dare say I had never seen handling this amount of data nicely in application level without even using a line of SQL code, it's awesome!

Fire up visual studio and a simple console or MVC application and install the package via:

PM> Install-Package Z.BulkOperations

PM> Install-Pac... Continue

Handling custom error in mvc

In asp.net mvc there is an custom error in web.config like below:

  1. <customErrors mode="On">
  2.  <error statusCode="404" redirect="~/404.html"/>
  3.  </customErrors>

Sometimes you want to redirect the user to your own custom error controller and log the error message. You can handle it! Firstly create your own Error controller:

  1.  public class ErrorController : Controller
  2.     {
  3.         public A... Continue

Call Asp.net Web API from C#

If you search in the web for calling web API from C# Code not from URL, you will find lots of sample on get and hardly enough on POST! I don't know why but I want to share with you a simple example. As a usual open visual studio and create a web API project from MVC project template.

Suppose these two simple post and get API actions:

  1.         [HttpPost]
  2.         [Route("api/Test/PostValue")]
  3.         public IHttpActionResult Po... Continue

Multiple submit buttons in asp.net MVC

In asp.net MVC you can submit a form by @using(Html.BeginForm()). You can Post the model you have binded via this operation and command the begin form to post to a Post action:   @using(Html.BeginForm("Create","FooController")).

Now if you have more than one submit button to send the page content to different post action, there are few ways: one of them is to post the content to a specific action and then decide in it to redirect which action:

 Razor:

  1. <input type="submit" value="Field1" name=&quo... Continue

Why you can't project mapped entity in entity framework

If you have worked with entity framework for a long time with and linq of course, you probably have seen the Error: The entity cannot be constructed in a LINQ to Entities query. So when it happens and why? Think about the following peace of code:

  1. public IQueryable<Lesson> GetAllLessons(int termId)
  2. {
  3.     return from p in db.Lessons
  4.            where p.termId == termId
  5.            select ... Continue

Workflow as a Service

As you know in some complex services, WCF services will not be sufficient; Situation like online shopping in line transaction (the most famous sample!). you may choose workflow services in these kinds of cases to implement logic via work flow and expose it via windows communication services. With the .NET Framework 3.5, Microsoft has provided additional components to integrate workflows with (WCF) and The result of this integration is called workflow services.

Microsoft workflow like other workflows is implemented by activities and it is consist of two activities: sequence and flo... Continue

Ember Data

Ember.Js is another popular web application framework to build single page application based on MVC pattern. There is an interesting feature in ember which lets you handle integrated templates to update automatically when the underlying data changes by ensuring your HTML. Ember Data is just a data persistence library such as JSON API that maps client-side models to server-side data. You know, it provides something like ORM in client side.

Ember Data provides two adaptors: RESTAdapter and FixtureAdapterThe RESTAdapter is configured for use b... Continue

Why should I define container classes in C++

What's a container class?

It's a class which is used to hold objects in memory or external storage to clumping variables of the same type to make the sorting, searching, … easier. A container could store many entities and provide direct access to them like string class.  Needless to say, The size of the container depends on the number of the objects it contains. A Container usually defined as a class that gives you the power to store any type of data. A container class acts as a generic holder.

a container class is in two kinds: Heterogeneous and homo... Continue