Posts

Showing posts from 2012

Decimal Round() in C#

public static string roundNum(double num, int place)         {             string formatNum = num.ToString(System.Globalization.CultureInfo.InvariantCulture);             if (formatNum.Contains("."))             {                 string[] strSeparator = new string[] { "." };                 string[] strFormatNum = formatNum.Split(strSeparator, StringSplitOptions.None);                 string decimalPlaces = string.Empty;                 if (strFormatNum.Length > 0)     ...

How to get distinct rows from a DataSet or DataTable

    DataTable dtDistinct=ds.Tables[0].DefaultView.ToTable(true,"Floor_id");

Entity Framework

What is Entity Framework? The Microsoft ADO.NET Entity Framework is an Object/Relational Mapping (ORM) framework that enables developers to work with relational data as domain-specific objects, eliminating the need for most of the data access plumbing code that developers usually need to write. Using the Entity Framework, developers issue queries using LINQ, then retrieve and manipulate data as strongly typed objects.  The Entity Framework’s ORM implementation provides services like change tracking, identity resolution, lazy loading, and query translation so that developers can focus on their application-specific business logic rather than the data access fundamentals. To simply say it: Entity framework is an Object/Relational Mapping (O/RM) framework. It is an enhancement to ADO.NET that gives developers an automated mechanism for accessing & storing the data in database and working with the results in addition to DataReader and DataSet. Now the questio...

New Features in SharePoint 2013

Authentication Microsoft says that SharePoint 2013 Preview has been improved to make claims-based authentication easier to use. It extends support for application authentication via Open Authorization 2.0 (OAuth) as well as for server-to-server authentication. Users can grant apps in the SharePoint store and catalog access to certain resources and data. Server-to-server security tokens that contain user identity claims enable cross-server authenticated access between, say, SharePoint 2013 Preview and Exchange 2013 Preview. Business Connectivity Services There's been a bunch of new features added, including these: Support for OData Business Data Connectivity (BDC) connections, in addition to connections for WCF, SQL Server, and .NET assemblies. Automatic generation via Visual Studio 2010 of BDC models for OData data sources. An event listener with an event subscriber on the SharePoint 2013 Preview side, to enable SharePoint users to receive notifications of cha...

Custom DateTime Format in C#

Namespace : using System.Globalization; DateTime dt1 = DateTime.Now; dt1.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); "08/10/2012" dt1.ToString("dd/mm/yyyy", CultureInfo.InvariantCulture); "10/29/2012" dt1.ToString("dd/mm/yy", CultureInfo.InvariantCulture); "10/29/12" dt1.ToString("dd:mm:yy", CultureInfo.InvariantCulture); "10:29:12"

InProc Advantages and Disadvantages

InProc mode advantages InProc is default mode which works without any configuration. It is easiest option to implement because you don't need to configure anything. Just read and write session variables in code. Other modes, like SQLServer or StateServer modes require additional configuration. One more advantage of InProc mode is that you can put anything in session variables. State Server or SQL Server requires objects to be serializable. But, if you use InProc, you can save any object in session variable even if it is not serializable. InProc mode works on shared web hosting. State Server is usually not allowed, and some shared web hosting providers give option to use SQL Server. In the other hand, InProc works in any hosting package.     InProc mode disadvantages Reliability is first problem when using InProc. When using InProc mode, all sessions are lost whenever web application restarts. Restart could happen very frequently because of numerous re...

Difference between Machine.config and Web.config

Difference between Machine.config and Web.config Machine.config is automatically installed when you install .NET Framework or Visual Studio. Net. Web.config is automatically created when you create an ASP.Net web application project. Machine.config is called machine level configuration file. Only one machine.config file exists on a server. Web.config is called application level configuration file.  Machine.config file is at the highest level in the configuration hierarchy. Web.Config file inherits setting from the machine.config

Label vs Literal

Label vs Literal: Label: <asp: Label id="lblMessage" runat="server" CssClass="anyclass" Text="My Label" /> will be rendered as: <span id="ctl00_ContentPlaceHolder1_lblMessage" class="anyclass">My Label</span> //assuming you are using masterpage Literal: <asp:Literal id="ltrMessage" runat="server" Text="My Literal" /> will be rendered as: My Literal  In any case (with or without masterpage), extra <span> element with id is added to rendered HTML. You can see from the difference in rendering of Label and Literal control that Labels should be used only when any kind of styling needs to be applied to the Text rendered by Label. In my case, most of the time we are giving styles to the TD element and no extra styling required for Text inside TD element. In that case, you must use Literal control to minimize the amount of HTML rendered in browser.

Design Patterns for developing SharePoint 2010

Image
Design Patterns for developing SharePoint 2010 SharePoint Design Patterns: Here are the few design patterns that can be used when creating custom designs, Repository MVP Service Locator Repository Pattern: Context: In many applications in SharePoint, the business logic accesses data sources such as SqlServer, SharePoint List, and Web services. Directly accessing the data source can result the following: Duplicate Code A higher potential for programming errors Week Typing of business data Difficulty to centralizing data related policies Objective: Use the Repository pattern to achieve one or more of the following objectives: You want to maximize the amount of code that can be tested with automation and to isolate the data layer to support unit testing. You access the data source from many locations and want to apply centrally managed, consistent access rules and logic. You want to implement and centralize a caching ...