Archive

Archive for November, 2012

Convert DataTable To List

November 30, 2012 Leave a comment

static List<string[]> ConvertTable(DataTable table)
        {
            return table.Rows.Cast<DataRow>()
                .Select(row => table.Columns.Cast<DataColumn>()
                    .Select(col => Convert.ToString(row[col])).ToArray()).ToList();
        }
Advertisements

Backup Time Information For a Database

November 30, 2012 Leave a comment

select dbinfo.Name , COALESCE(CONVERT(VARCHAR(20),backuplog.backup_finish_date,100 ),”) as BackupTime
FROM sys.sysdatabases dbinfo
LEFT OUTER JOIN msdb.dbo.backupset backuplog ON backuplog.database_name = dbinfo.name
where dbinfo.Name=’DataBase Name’

Get Row counts of all tables in a database

November 27, 2012 Leave a comment

SELECT sysobjects.name TableName,sysindexes.rows TotalNoRow

FROM sysobjects inner join sysindexes ON sysobjects.id = sysindexes.id

WHERE type = ‘U’AND sysindexes.IndId < 2

order by sysindexes.rows desc

Restore Database

November 27, 2012 1 comment

Restore the logical file from the backup file

RESTORE FILELISTONLY
FROM DISK = ‘Backup file full path\filename.extension’

Restore the database in same path as in the backup database path and file name

Restore database DBName

to disk=’Backup file full path\filename.extension’

Restore the database with different logical name and path

RESTORE DATABASE DBName
FROM DISK = ‘Backup file full path\filename.extension’
WITH MOVE ‘YourMDFLogicalName’ TO ‘New Restore file full path\filename.extension’,
MOVE ‘YourLDFLogicalName’ TO ‘New Restore file full path\filename.extension’

Reference:

Pinal Dave (http://blog.sqlauthority.com/2007/02/25/sql-server-restore-database-backup-using-sql-script-t-sql/)

Pinal Dave (http://blog.SQLAuthority.com)

Categories: SQL

Find Current Location of Data and Log File of All the Databas

November 27, 2012 Leave a comment

We restored the database in the client development server for out client development and testing purpose.This time we need to take back and restore it in the client production machine. while am doing this we are unable to restore it. Later we found in client development machine client move the ‘.mdf and .ldf’ to different folder.

SELECT name, physical_name AS current_file_location
FROM sys.master_files

The above SQL script helped us to sort out the issue. We can also use this same script to clean up the junk database folder.

 

Categories: SQL

Contract in WCF

November 23, 2012 Leave a comment

Contract

A contract is a Standard way of describing way a service can do. In the real world contract is an agreement between two or more parties about doing service or some other things. Similarly in WCF it is the agreement between the Service and Clients, through which message can be passed to and from service endpoints.

The Contract consist of three major types

1)      Service contract

2)      Data contract

3)      Message contract

4)      Polices and binding

Service Contract

Service contract is a class or an interface that specifies the direction and type of message. This contract describes the operation, that can be avail by our world. Example: – To know the current market price based on the company shares. So Service contract is a gate way to the external application to avail the functionality and operations and there must be atleast one operation contract.

Data Contract

Data Contract describe data structures that are used by the service to communicate with clients. It also describes the custome data type which is exposed to the client. The system define datatype are automatically identify by the client, because it is already define in XML schema defination language doument(XSD), but custom created class or datatype cannot be identified by the client.

Example:- Product datatype, by using  DataContract client can understand that Product is the custom datatype for a method that is returning or passing the parameter.

If ‘DataMember’ attributes are not specified for a properties in the class that property can’t be passed to or from web service.

For more:- http://msdn.microsoft.com/en-us/library/ms733127(v=vs.100).aspx

Message Contract:-

Message contract allow the service to interact directly with messages. It can be typed or untyped and are useful in interoperability. Message contract provide control over the soap header and bodies. MessageContracts are used to explicitly describe the soap message format.

WCF runtime provide SOAP message formatting for comminication between client and service.If it is not meeting your requirements then we can create our own message format. This can be achieved by using Message Contract attribute.

For more:- http://msdn.microsoft.com/en-us/library/ms730255(v=vs.100).aspx

Policy and Binding

Policies and bindings stipulate the conditions required to communicate with a service. For example, the binding must (at a minimum) specify the transport used (for example, HTTP or TCP), and an encoding. Policies include security requirements and other conditions that must be met to communicate with a service.

WCF Archicture

November 23, 2012 Leave a comment

Contract

A contract is a Standard way of describing way a service can do. In the real world contract is an agreement between two or more parties about doing service or some other things. Similarly in WCF it is the agreement between the Service and Clients, through which message can be passed to and from service endpoints.

Service Runtime

Service runtime define the behavior of the service. we can achieve through puts, reliability and performance using various WCF Service behavior techniques and handling errors. Most application differs widely in their scalability and performance strategies. WCF service behaviors provide various possible ways to configure key run time behaviors.

Message Layer

This layer defines what kind of formats and data exchange patterns can be used during service communication, this communication are happening through channels. Normally the channels are used to send and receive messages to and from  the service endpoint. There are two parts of Channels

1) Transport Channel

2) Protocol Channel

Activation and Hosting

Once WCF service is ready to make it available to outside world service can be hosted in following types

1)      In IIS

2)      As Windows Activation Service

3)      Self Hosting

4)      Windows service

Categories: WCF Tags: ,
%d bloggers like this: