Click here to Skip to main content
15,895,798 members
Articles / Hosted Services / Azure

Kerosene ORM: a dynamic, configuration-less and self-adaptive ORM for POCO objects supporting a SQL-like syntax from C#

Rate me:
Please Sign up or sign in to vote.
4.96/5 (71 votes)
1 Mar 2015CPOL35 min read 548.3K   4.6K   212  
The seventh version of the dynamic, configuration-less and self-adaptive Kerosene ORM library, that provides full real support for POCO objects, natural SQL-like syntax from C#, and advanced capabilities while being extremely easy to use.
--- =============================================
PRINT 'DELETING CONTENTS...'
--- =============================================
USE KeroseneDB
GO

PRINT 'Deleting contents from Employees...'
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Employees]') AND type in (N'U'))
DELETE FROM [dbo].[Employees]
GO

PRINT 'Deleting contents from Countries...'
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Countries]') AND type in (N'U'))
DELETE FROM [dbo].[Countries]
GO

PRINT 'Deleting contents from Regions...'
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Regions]') AND type in (N'U'))
DELETE FROM [dbo].[Regions]
GO

--- =============================================
PRINT 'SETTING INITIAL CONTENTS...'
--- =============================================

USE KeroseneDB
GO

--- REGIONS
PRINT 'Inserting contents in Regions...'

INSERT INTO [dbo].[Regions] ( Id, Name, ParentId )
VALUES
	( '000', 'World', null )

	,( '100', 'Americas', '000'  )
		,( '110', 'North America', '100' )
			,( '111', 'Canada', '110' )
			,( '112', 'US Administration', '110' )
			,( '113', 'US Commercial', '110' )
		,( '120', 'Central America', '100' )
	
	,( '200', 'Europe, Middle East & Africa', '000' )
		,( '210', 'EMEA North', '200' )
		,( '220', 'EMEA South', '200' )
			,( '221', 'West Mediterranean', '220' )
			,( '223', 'Middle East', '220' )
			,( '225', 'Africa', '220' )
		,( '230', 'EMEA Central', '200' )
		,( '240', 'EMEA East', '200' )
	
	,( '300', 'Asia and Pacific', '000' )
		,( '310', 'Japan', '300' )
GO

--- COUNTRIES
PRINT 'Inserting contents in Countries...'

INSERT INTO [dbo].[Countries] ( Id, Name, RegionId )
VALUES
	( 'ca', 'Canada', '111' )

	,( 'zz', 'US Administration', '112' )
	,( 'us', 'United States of America', '113' )

	,( 'mx', 'Mexico', '120' )
	
	,( 'uk', 'United Kingdom', '210' )
	,( 'ie', 'Ireland', '210' )
	
	,( 'es', 'España', '221' )	
	,( 'pt', 'Portugal', '221' )
	,( 'it', 'Italy', '221' )

	,( 'ae', 'United Arab Emirates', '223' )
	
	,( 'za', 'Republic of South Africa', '225' )
	
	,( 'jp', 'Japan', '310' )
GO 

--- EMPLOYEES
PRINT 'Inserting contents in Employees...'

INSERT INTO [dbo].[Employees]
	( Id, Active, ManagerId, CountryId, FirstName, LastName, BirthDate, JoinDate, StartTime, Photo )
VALUES
	( '1001', 1, null, 'us', 'Tom', 'Thomsom', '1969-9-12', '2002-1-24', '10:12:45', null )
		,('1002', 1, '1001', 'us', 'Dave', 'Alistair', '1959-11-23', '2001-11-9', '18:00:45', null )
		,('2001', 1, '1001', 'uk', 'Mohammed', 'Al Yashira', null, null, null, null )
			,('2002', 1, '2001', 'uk', 'Andrew', 'Mc Quanty', '1970-11-23', '2001-11-9', '18:00:45', null )
			,('2003', 1, '2001', 'es', 'David', 'Perez de Manto', null, null, null, null )
				,('2005', 1, '2004', 'es', 'Juan', 'Perez Gomez', null, null, null, null )
					,('2008', null, '2005', 'es', 'Fernando', 'Quesero Villaverde', null, null, null, null )
					,('2009', null, '2005', 'es', 'Antonio', 'Martinez del Alamo', null, null, null, null )
				,('2006', 1, '2004', 'za', 'Richard', 'Mc Donnel', null, null, null, null )
					,('2010', 1, '2006', 'za', 'Paul', 'Brown', null, null, null, null )
					,('2011', 1, '2006', 'za', 'Nicole', 'Weather', null, null, null, null )
			,('2004', 1, '2001', 'ae', 'Hassan', 'El Auly', '1969-1-15', '2001-11-9', '18:00:45', null )
				,('2007', 1, '2005', 'ae', 'John', 'Burrogough', null, null, null, null )
		,('3001', 1, '1001', 'jp', 'Asira', 'Yamamoto', '1967-2-20', '2003-8-23', '8:00:00', null )
GO

--- =============================================
PRINT 'SET OF INITIAL CONTENTS LOADED...'
--- =============================================

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Spain Spain
mbarbac has worked in start-ups, multinational tech companies, and consulting ones, serving as CIO, CTO, SW Development Director, and Consulting Director, among many other roles.

Solving complex puzzles and getting out of them business value has ever been among his main interests - and that's why he has spent his latest 25 years trying to combine his degree in Theoretical Physics with his MBA... and he is still trying to figure out how all these things can fit together.

Even if flying a lot across many countries, along with the long working days that are customary in IT management and Consultancy, he can say that, after all, he lives in Spain (at least the weekends).

Comments and Discussions