Wednesday, July 25, 2012

Advantages and Disadvantages of Entity Framework in .NET

The EF is essentially an O/R mapping tool. It takes care of object persistence for you. In other words, it acts as your data layer. writing applications using entity framework saves lot of development time and its good..if we are developing enterprise applications, we need to think about performance..all in all its good for small applications..

  1. Advantages : One common syntax ( LINQ / Yoda ) for all object queries whether it is database or not , Pretty fast if used as intended , easy to implement SoC , less coding required to accomplish complex tasks
    Disadvantages : you have to think in a non traditional way of handling data , not available for every database
  2. Disadvantage: If there is any schema change in database FE won’t work!!! You have to update the schema in solution as well!!!
    Advantage: Its fast and straight forward using LINQ/FE objects For Add/Modify/Delete/Update.
  3. Advantages:-Easy to map business objects (with drag & drop tables on environment).
    -It keeps a good performance when you work with a small / middle domain model.
    Disadvantages:-It's limited when you work with a huge domain model.
    -Scalability.

Thursday, April 19, 2012

Web Performance Best Practices and Rules By Yahoo DEVELOPER Team

Yahoo!'s Exceptional Performance team has identified 34 rules that affect web page performance. YSlow's web page analysis is based on the 23 of these 34 rules that are testable. Click each performance rule below to see the details.
  1. Minimize HTTP Requests
  2. Use a Content Delivery Network
  3. Avoid empty src or href
  4. Add an Expires or a Cache-Control Header
  5. Gzip Components
  6. Put StyleSheets at the Top

Object cannot be cast from DBNull to other types. How to resolve this Exception Message?

Error Message: Object cannot be cast from DBNull to other types.

Solution: This exception occurred because the data type of data column of data row accepts null values, but the data type in C# not. All the data type that are "value types" (struct) don´t accepts null values.

Wednesday, April 18, 2012

Maximum SharePoint Content DB Capacity

100GB is not the limit, its actually a best practise. This post lists out few suggestions. The following represents Microsoft's guidance and best practices on content databases, as specified in various places on technet.microsoft.com:

  1. Limit the content database size to 100GB; use multiple content databases if necessary.
  2. Create multiple data files and spread them across multiple disks; only create files in the primary file group.
  3. The number of data files should be less than or equal to the number of core CPUs; count dual core processors as two CPUs; count each processor that supports hyper-threading as one CPU.

Tuesday, April 17, 2012

JQuery Autocomplete Key/Value

This solution with key/value with cascading Auto complete with web service.

This JQuery Script

<script type="text/javascript"> 
    $(document).ready(function () { 
      $("[id$='txRequesterName']").attr('disabled', true); 
      $("[id$='txAssetName']").attr('disabled', true); 
      $("[id$='txCompanyName']").autocomplete({ 
        source: function (request, response) { 
          $.ajax({ 
            type: "POST", 
            url: "WebService.asmx/GetCompany", 
            dataType: "json", 
            data: "{\"companyName\":\"" + request.term + "\"}", 
            contentType: "application/json; charset=utf-8", 
            success: function (data) { 
              response($.map(eval(data.d), function (item) { 
                return { 
                  label: item.label, 
                  value: item.label, 
                  id: item.value 
                } 
              })); 
            } 
          }) 
        }, 
        minLength: 1, 
        select: function (event, ui) { 
          $("[id$='txCompanyID']").val(ui.item.id); 
          $("[id$='txRequesterName']").attr('disabled', false); 
        }, 
        change: function (event, ui) { 
          $("[id$='txRequesterName']").val(''); 
          $("[id$='txRequesterName']").attr('disabled', false); 
        } 
      }); 

Sunday, April 15, 2012

Differences between value type and reference type?


Value Type Reference Type
Value type variable directly contain value itself. Reference type variable contain the address of object where the values are placed in memory. Or we can say they store the reference to object.
All value types are implicitly derived from System.ValueType. They are derived from System.Object class.
They doesn’t support inheritance. Means they are sealed implicitly. They can be inherited. They are internal by default.
A value type variable can’t be assigned value null. An object can have value null.
They can be declared without new operator. They can’t be declared without new operator.

Differentiate between Structure and Class in .net?

                        Structure

                           Class

Structures are value type, i.e. variable of struct type directly contain the data of structure

Classes are reference type, i.e variable of class (known as object) contain the reference to data.

Do not require, urgently, new operator to do its instantiation. Or instantiation can be done without new operator.

Do require new operator to do instantiation.

Each variable will have its own set of data even if they have same values.

More than one object can have reference to same data.

Default Value of a struct type can’t be null.

Default value of an Object of a class type is null.