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.      ... 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... 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

Explicit interface in C#

You have used millions of times, but you maybe don’t know what they call it (I just saw it and I didn't know too). Suppose these two interfaces with a member Called WithDraw():

 

  1.  public interface IBankingA
  2.     {
  3.         void WithDraw();
  4.     }
  5.  
  6.     public interface IBankingB
  7.     {
  8.         void WithDraw();
  9.     }

Now If you w... Continue

Introducing book: Pro Asp.net 4.5 in C#

About two years ago, I read some chapters of Pro asp.net 3.5 (it was the second edition of the book). I remember that I didn't dig in some chapter like lifecycle and Context, Modules, Handlers, Caching, Managing paths, Configurations, …  but now as I really need to know what's exactly going on the behind of asp.net I've decided to read this book in detail. In my opinion it's necessary to every asp.net developer as it really convers more about asp.net and it's frameworks. 

This book is in my books queue and will start reading of... Continue

How to turn off the caches in asp.net MVC

I've written about different kinds of caching in asp.net MVC here, I just wanted to turn off some specific caches in my project and found a way to do that, you can do that by overriding OnResultExecuting:

  1. public class TurnOffCache : ActionFilterAttribute
  2. {
  3.     public override void OnResultExecuting(ResultExecutingContext filterContext)
  4.     {
  5.         filterContext.HttpContext.Response.Cache.SetE... Continue

Why brackets are required for try/catch in C# ?

Have you ever think about that!? You don’t need to put bracket statement of if/else condition if your statement is not multiline. Needless to say, if you want to put if/else condition with just one line statement, it would be something like this:

  1.             if (a == b)
  2.                 Console.WriteLine("");
  3.             else
  4.                 Console.Write... Continue

Attribute routing with asp.net MVC5

Until the latest version of asp.net (asp.net mvc4), routing was handling by Convention-based routing to matches a URI to an Action in a separate class (RouteConfig) registered in global.asax. but in asp.net MVC5  you can use attribute routing. It means you can use attribute to set routes to your actions. It's too easy getting started with attribute routing, you just need to refer RouteConfing.cs in App_Start folder and add  routes.MapMvcAttributeRoutes(); in RegisterRoutes:

  1. &... Continue

How to create portable area in asp.net mvc4

Sometimes you need to separate your areas from MVC project into another class library for making it readable and better management.  you can do that by using features of MvcContribe project. I recommend you to create your area in asp.net MVC and then transfer the content to the class library:

 

Contrib

 

Now add a class library to your solution and transfer the content(Controllers, ... Continue

How to persist a list of value objects in Domain Driven Design

I'm really interested in to write about domain driven design, but it doesn't come into a simple blog post! real world application in Domain driven design approach are usually big, complex and hard to understand the business. I'm gonna to give an example about the persisting the list of value objects, it's just an implementation example that everybody knows the business.

Suppose that we are going to persist the list of tags with blog post. You know, in DDD  value objects should persist with aggregate root and to doing any kind of operation with value object you... Continue