Skip to main content

Posts

Get C# class declaration from Oracle Table

Select distinct 'public ' || case Lower(DATA_TYPE)              when 'raw' then 'Guid?'              when 'number' then 'Decimal?'             when 'char' then 'string'             when 'date' then 'DateTime?'             when 'decimal' then 'decimal?'             when 'nvarchar' then 'string?'             when 'uniqueidentifier' then 'Guid?'             when 'varchar2' then 'string'             else 'UNKNOWN_' || DATA_TYPE end|| ' '  || replace(initcap(replace(Column_name,'_',' ')),' ','') || ' { get; set; }' ,  all_tab_columns.column_id   from all_tab_columns where table_name= upper('SPA_DISCOUNT_GROUP')   order by all_tab_columns.column_id select *   from all_tab_columns where table_name= upper('SPA_DISCOUNT_GROUP') --------------- Result --------------
Recent posts

Get C# class Declaration from SQL Table structure

Get C# class Declaration from SQL Table structure ------------ CODE ---------- to be executed in SQL --------- declare @TableName sysname = 'Transaction_document' declare @Result varchar ( max ) = 'public class ' + @TableName + ' {' select @Result = @Result + '     public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; } ' from (     select          replace ( col . name , ' ' , '_' ) ColumnName ,         column_id ColumnId ,         case typ . name              when 'bigint' then 'long'             when 'binary' then 'byte[]'             when 'bit' then 'bool'             when 'char' then 'string'             when 'date' then 'DateTime'             when 'datetime' then 'DateTime'             when 'datetime2' then &

Load XML data in DataTable and use LINQ on it

XML Document Structure - xml version = " 1.0 " encoding = " utf-8 " standalone = " yes " ?> < Root >   < Type TypeName = " Functions " >     < Details FunctionName = " InActiveUsers_Mail " ClientList = " Etihad,Malasia " />     < Details FunctionName = " UnAssignedUsers_Mail " ClientList = " Etihad,Virgin " />   </ Type >   < Type TypeName = " Mails " >     < Details FunctionName = " InActiveUsers_Mail " ClientList = " Etihad,Malasia " />     < Details FunctionName = " UnAssignedUsers_Mail " ClientList = " Malasia,Virgin " />   </ Type > </ Root > Load XML Document in DataTable - XmlDocument xmlDoc = new XmlDocument (); xmlDoc.Load( Environment .CurrentDirectory + "\\ClientWiseFunctionality.xml" ); XmlNodeList elemList = xmlD
When your keyboard does not display single quotes (') on single click but when it is clicked again displays 2 single quotes ('') , do the following settings Control Panel > Clock, Language and Region > Region and Language > Keyboards and Language. Click the “Change keyboards” button under “Keyboards and other input languages”. Now the chances are you have chosen “US international”. This behaviour is default on this keyboard setup. Click the “Add” button and add “US”. Change to this and remove US international and your keyboard should start working as expected.  

Converts a byte array to a string

///   ///   Converts a byte array to a string ///   ///   Byte array to be converted ///   string representation of the byte array private   static   string  byteArrayToString( byte [] arrInput) { StringBuilder  sb =  new   StringBuilder (arrInput.Length * 2); for  ( int  i = 0; i < arrInput.Length; i++) sb.Append(arrInput[i]. ToString( "X2" )); return  sb.ToString().ToUpper(); } private   static   byte [] StringToByteArray( string  textString) { UTF8Encoding  encoding =  new   UTF8Encoding (); return  encoding.GetBytes(textString); }

Serialization

Serialization is a process where an object is converted to a form , able to store and transport to different places. Used for: to store object to hard drive send object over the network [Without serialization the remoting will be impossible] To serialize a class add [Serializable]  attribute in front of the class definition if you dont want to serialize something in this 'serialized' class use [NonSerialized]  before it Note: properties are not serialized To store the data of a class into a file in binary format     Store myStore = new Store(); // create object of a class to be serialized     myStore.stockCount = 50; // pass value to the variable     FileStream flStream = new FileStream("MyStore.dat", FileMode.OpenOrCreate, FileAccess.Write);     try     {         BinaryFormatter binFormatter = new BinaryFormatter(); //to store the data to a file in binary format.         binFormatter.Serialize( flStream, myStore);        //Seralize method stores the dat

Random Notes

Infragistic controls / 3rd party controls are slow. bcos they have additional properties .. they need time to load which can slow a website. By replacing these conrols by user deigned .net controls  we made the websit faster frm 3.3 seconds to 2 sec.  also redesign the pages to have better look and feel SQL profiler is used to see the performance of a sql script. By % how much time taken by what To return 2 values from a method... 1 can be returned by normal process, other by reference SQL also has an Execution palnner -> (Query->include execution planner ) Ctrl + M to get the current user of the system -  @System.Security.Principal.WindowsIdentity.GetCurrent().Name;

Create a Maintainance Plan on SQL

- There are two ways to create a maintenance plan: you can create a plan using the Maintenance Plan Wizard, or you can create a plan using the design surface. The Wizard is best for creating basic maintenance plans, while creating a plan using the design surface allows you to utilize enhanced workflow. To create or manage Maintenance Plans, you must be a member of the sysadmin fixed server role. Note that Object Explorer only displays maintenance plans if the user is a member of the sysadmin fixed server role. The Maintenance Plan Wizard helps you set up the core maintenance tasks to make sure that your database performs well, is regularly backed up, and is free of inconsistencies. The Maintenance Plan Wizard creates one or more SQL Server Agent jobs that perform these tasks on local servers or on target servers in a multiserver environment. Execution can be at scheduled intervals or on demand. Maintenance plans can be created to perform the following tasks: - Reorganize the

WebService - all about it

This is from  4guysfromrolla.com A Web Service is an external interface provided by a Web site that can be called from other Web sites. For example, a financial company may make up to the minute stock quotes available via a Web Service for those who do their trading with that company. This information could be read from a Web page and displayed, or read from a stand-alone application on a customer's desktop computer. my Web Service should provide other Web sites the ability to: 1.      View a listing of all of the FAQ categories 2.      View a listing of all of the FAQs for a particular category 3.      View the "Question" (but not the Answer) for a particular FAQ Creating Web Services is quite simple. Start by creating a  .asmx  file.  The Web Service is created as an ordinary class; the methods that have the   macro before them indicate the method is accessible via the Web Service. For the ASPFAQs.com Web Service, we will create three Web Service-acces

Threading in C#

C# supports parallel execution of code through multithreading A thread is an independent execution path, able to run simultaneously with other thread http://www.albahari.com/ threading/

WCF Basic

WCF - windows communication foundation (.net 3.0) - communication framework - enables us to expose CLR type services and consume exisitng services as CLR types - Different communication technologies in the world - webservices (asmx), web services enhancements(wse), messaging (msmq), .net enterprise services (ES), .net remoting - used for building service oriented applications - eg: websevice for weather - consumes zip code and outputs forecast - wcf service is based on contract ( implemented  as an interface decorated with the attribute [ServiceContractAttribute] ) [ServiceContract] public interface IWeatherForecastService {     [OperationContract]     public WeatherForecast GetForeCast(int zipCode); } - Address : where the service will be found [ServiceContract] public interface IWeatherForecastService {     [OperationContract]     public WeatherForecast GetForeCast(int zipCode); } ABC od WCF - Address: where the service will be found scheme://domaon[:port]/path (e.g.:  http