Tip : Code Structure C#
Feb03

Tip : Code Structure C#

Welcome to CodeSpread! As a developer, I always stress on developing a habit of following the best practices to structure the code. It helps me to easily navigate through the code and also saves a lot of effort in searching for some particular items. Below is the sample structure and example: using statements Constants / Read-only fields Private Members Enumerations Public members Protected members Constructors Properties Public methods Private methods //using statements Using System Using System.Web namespace Controllers { public class SampleController {   //Constants / Read-only fields public const int numofitems=10; //Private Members private string _samplestring = string.Empty; //Enumerations public enum months { January = 1, February, March, April, May, June, July, August, September, October, November, December };   //Public members public  int StartDate =string.Empty;   //Protected members protected int EndDate ==string.Empty; //Constructors public SampleController () { }   //Properties public string Date { get; set; } //Public methods public string GetStartDate() { } //Private methods private int numOfItems() { }     Related articles across the web C# Coding Standards CLS Compliance?...

Read More
OLAP : On-line Analytical Processing
Jan06

OLAP : On-line Analytical Processing

What is OLAP? We know that there are two kinds of database applications available, OLAP and OLTP. Before we go for OLAP, I would like to tell you something about OLTP. OLTP is On-line Transaction Processing. By transaction, we mean any operation including INSERT, UPDATE, and DELETE statements. And, just like any other transaction system, the main concern here is ACID rules. Let’s take an example of banking transaction systems, where a large number of users simultaneously perform transactions. In this case, Online Transaction processing (OLTP) applications provide optimal environment for concurrency and atomicity of transactions. OLAP is On-line Analytical Processing and its main concern is analysis. This is how OLAP is different from OLTP, where the main concern is concurrency and atomicity. Now, With OLTP we always have a consistent state of data but how this data can be useful to business? OLAP has an answer to it. In OLAP, the current data is analyzed for any trends or summarize through many filters. The resultant data is not changed or tampered with anytime. “Because of OLAP, data speaks for itself.” For example: With the help of OLAP component; Sales, Marketing, Budgeting and Forecasting can provide multi-dimensional analysis and reporting. What are the advantages of OLAP? Multi-dimensional: Multi-dimensional views of various kinds of business activities. Decision Support: Analytical capabilities promote decisions. Complex Calculations Support: When it comes to determining future trends then complex calculations are necessary like averages and percentage growth. Access from individual’s point of view:  Access to fast, consistent, interactive access to a wide variety of possible views of information. What are the types of OLAP? There are three basic types of OLAP : MOLAP relies on a multidimensional database. ROLAP relies on a relational database. HOLAP is a hybrid model. More Details are given below: MOLAP: Multidimensional Online Analytical Processing uses a multidimensional database stored in various cubes. This information is pre-summarized and optimized, due to which, fast data retrieval is possible. Also, a range of complex calculations are already performed. ROLAP: Relational Online Analytical Processing uses a relational database. ROLAP do not use pre-calculated data cubes like MOLAP. ROLAP uses regular SQL statement to query the standard relational database. Although, it gives the appearance of traditional OLAP’s slicing and dicing functionality. HOLAP: Hybrid Online Analytical Processing is a hybrid approach which combines the advantages of MOLAP and ROLAP. Here, database divides data between relational and specialized storage like the small aggregated totals are stored in a multidimensional database while large quantities of detail data is stored in the relational database. So we have advantage of both pre-summarized/optimized cubes and relational database....

Read More
Simply LINQ: What,Why and How.
Dec24

Simply LINQ: What,Why and How.

What is LINQ? LINQ is Language-Integrated Query (LINQ). It is primarily an extension to the language’s capability where it adds query expressions which processes objects and data. It is a one stop solution to all the query processing as now there is no need to learn a different query language for each type of data source: SQL databases, XML documents etc. Why LINQ? Type safe. IntelliSense support. Tables are available as classes. SQL generated is well structured and optimized. Targets Business rules. Easy to debug with the visual studio’s debugger. Easy to deploy as being a part of DLL. LINQ to SQL parameterizes input so better security. And,best of all, SIMPLE. An example: var Employee= from emp in Employees where emp.name="CodeSpread" select emp; Let’s see the flow, First the ‘from’ clause points to the data source which is ‘Employees’. Next, ‘where’ specifies the filter which is the employee name. Lastly, ‘select’ statement returns the result set. There are three main components of LINQ. Standard Query Operators Language Extensions LINQ Providers Standard Query Operators: The standard query operators can be simply referred to as methods in LINQ .There are two sets of LINQ standard query operators, Operates on objects of type IEnumerable and, Operates on objects of type IQueryable. var result= from emp in Employees orderby emp.empid select emp.name; But it doesn’t look like method, let’s write it again. var result= Employees. Select(emp=>emp.name).OrderBy(emp=> emp.empid); Looks good now. Both of the above examples just vary in syantax. There are many other Standard Query Operators available which we will enlist in a future article. Language Extensions: Implicitly Typed Variables. Anonymous Types. Object Initializers. Lambda Expressions LINQ Providers: These are data source-specific implementations for ex: in-memory object collections, Microsoft SQL Server databases, ADO.NET datasets and XML documents. LINQ to Objects – Executes a LINQ query against a collection of objects For an in-memory object collections like arraylist of employees, var result= from emp  in empList where emp.name="CodeSpread" select emp; LINQ to XML – Executes an XPATH query against XML documents. XElement root= XElement.Load("\..\Employees.xml"); IEnumerable employee= root.Elements(); LINQ to SQL – Executes LINQ queries against Microsoft SQL Server. For a Database called company and table called customers. IQueryable customer = from cust in company.Customers where cust.name== "CodeSpread"  select cust; LINQ to ADO.NET datasets– Executes LINQ queries against ADO.NET DataSets. Same example as above where the data is queried from a dataset instead of directly from a...

Read More
Interview Question: Why Garbage Collection required?
Dec13

Interview Question: Why Garbage Collection required?

What is garbage collection? In two words “Memory Management”. In two lines “Managing the lifetime of object starting from creation, allocation and release it back to free memory pool.” Why it is required? We have two scenarios here, Case 1: Where resources are not released. Scenario: Resources will keep on getting consumed and will result in memory leak. Case 2: Where resources are released irrespective of still being used in the code. Scenario: May result in null pointers exceptions, corrupted memory areas or loss of data. Garbage Collector manages the lifetime of all objects and avoids any early-release or late-release of...

Read More
Few lines about WCF metadata
Dec07

Few lines about WCF metadata

What is WCF metadata? WCF generates metadata for service endpoints and this metadata is used to describe how to interact with the service’s endpoints. This information is used by Svcutil.exe to generate proxy for accessing the service. WCF metadata is exposed by one or more metadata endpoints similar to service endpoints. They have an address, a binding, and a contract. This information is sent over standard protocols, such as WS-MetadataExchange (MEX) and HTTP/GET requests. Also, Metadata can be added to a service host through configuration or imperative code. We can see the below example for adding metadata endpoints to the service in the configuration file. <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> What are the bindings available for Service Metadata?  mexHttpBinding for HTTP protocol.  mexHttpsBinding for HTTPS security layer.  mexNamedPipeBinding for named pipe.  mexTcpBinding for TCP protocol. Can Service Metadata be tampered? Service metadata can be tampered with or spoofed. Spoofed data can be used to redirect client to a malicious service. Metadata documents can be large and are frequently saved to the file system. How to protect Service Metadata? Use a secure binding to request service metadata. Publish service metadata over HTTPS, use mexHttpsBinding and configure a server certificate for the...

Read More
Difference Between Transport and Message Security in WCF
Dec06

Difference Between Transport and Message Security in WCF

Transport Security in WCF As the name suggests, it is concerned with security of communication between client and the service over a network protocol. It guarantees the confidentiality and integrity of messages at transport level. Transport security is required for point-to-point security between the two endpoints and is dependent on the transport [protocol] being used. The simplest approach is to encrypt and send it over HTTPS protocol. To encrypt/sigining the contents, Secure Sockets Layer(SSL) is used. Note: Transport security is available on all of the bindings except for wsDualHttpBinding. Example <bindings> <wsHttpBinding> <binding name="SecureWsHttpBinding"> <security mode="Transport"> </security> </binding> </wsHttpBinding> </bindings> Message Security in WCF As the name suggests, it is concerned with security of message between client and the service. It is not dependent of the network protocols. It guarantees the confidentiality and integrity of the messages at the message level. Message security ensures encryption and signing of the messages. Note: Message security is available on all of the bindings except for netNamedPipeBinding and MSmqIntegrationBinding. <bindings> <wsHttpBinding> <binding name="SecureMessageBinding"> <security mode="message"> </security> </binding> </wsHttpBinding> </bindings> Media, on any given day,is a better way of conveying 1000s words of explanation so below are two images taken from msdn which perfectly shows the differences. Ref:MSDN Just concentrate on the locks of XML file being transmitted and the transport channel being...

Read More
Page 1 of 512345