Click here to Skip to main content
15,895,538 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.2K   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.
// ======================================================== 
namespace Kerosene.ORM.WCF
{
	using Kerosene.ORM.Core;
	using Kerosene.Tools;
	using System;
	using System.ServiceModel;

	// ==================================================== 
	/// <summary>
	/// Represents the server side of a WCF connection, or data context, with an arbitrary underlying database
	/// managed by this proxy.
	/// </summary>
	[ServiceContract(SessionMode = SessionMode.Required)] // Each session will use its own proxy
	[ServiceKnownType("GetKnownTypes", typeof(KTypesWCF))] // To obtain the registered types to be used with WCF
	public interface IKProxyWCF : IDisposableExtended
	{
		/// <summary>
		/// Invoked when connecting with a client.
		/// </summary>
		/// <param name="package">The optional package of arbitrary information sent by the client when it sent
		/// the connection request, that this server side proxy can use to tailor the details of the services it
		/// will provide to that client.</param>
		[OperationContract]
		Guid OnProxyConnect(DeepObject package = null);

		/// <summary>
		/// Invoked when the client wants to disconnect from this server side proxy.
		/// </summary>
		[OperationContract]
		void OnProxyDisconnect();

		/// <summary>
		/// Invoked to open the actual server side connection with the arbitrary underlying database this server
		/// creates to serve the requests of its client
		/// <para>If the connection was already opened this method throws an exception.</para>
		/// </summary>
		[OperationContract]
		void OnLinkOpen();

		/// <summary>
		/// Invoked to close the server side connection with the arbitrary underlying database this server created
		/// to serve the requests of its client.
		/// <para>If the connection was not opened this method is merely ignored.</para>
		/// </summary>
		[OperationContract]
		void OnLinkClose();

		/// <summary>
		/// Invoked to get whether the server side connection with the arbitrary underlying database created by
		/// this server is opened or not.
		/// </summary>
		[OperationContract]
		bool OnLinkIsOpen();

		/// <summary>
		/// Invoked to start a new transaction at the server side or, if it was active already, to increase its
		/// nesting level.
		/// </summary>
		[OperationContract]
		void OnTransactionStart();

		/// <summary>
		/// Invoked to commit the transaction at the server side or, if its nesting level is greter than one, to
		/// decrease that nesting level.
		/// <para>This method is merely ignored is the transaction was not active.</para>
		/// </summary>
		[OperationContract]
		void OnTransactionCommit();

		/// <summary>
		/// Invoked to abort the transaction at the server side regardless of its nesting level.
		/// <para>This method is merely ignored is the transaction was not active.</para>
		/// </summary>
		[OperationContract]
		void OnTransactionAbort();

		/// <summary>
		/// Invoked to obtain the level of the transaction at the server side. A value of cero indicates that the
		/// server side transaction is not active.
		/// </summary>
		[OperationContract]
		int OnTransactionLevel();

		/// <summary>
		/// Invoked to create a new server side enumerator.
		/// </summary>
		/// <param name="text">The text of the command to be executed by the new enumerator.</param>
		/// <param name="pars">the list of parameters to be used to execute the command of the new enumerator.</param>
		[OperationContract]
		Guid OnEnumeratorCreate(string text, IKParameterCollection pars);

		/// <summary>
		/// Invoked to dispose the server side enumerator.
		/// </summary>
		/// <param name="uid">The server side uid that identifies the enumerator.</param>
		[OperationContract]
		void OnEnumeratorDispose(Guid uid);

		/// <summary>
		/// Invoked to execute the command associated with the server side enumerator. Returns the schema that
		/// describes the structure and metadata of the objects to return.
		/// </summary>
		/// <param name="uid">The server side uid that identifies the enumerator.</param>
		[OperationContract]
		IKSchema OnEnumeratorStart(Guid uid);

		/// <summary>
		/// Invoked to obtain the next record of the iteration, or null if no more records are available.
		/// </summary>
		/// <param name="uid">The server side uid that identifies the enumerator.</param>
		[OperationContract]
		IKRecord OnEnumeratorNext(Guid uid);

		/// <summary>
		/// Invoked to reset the server side enumerator.
		/// </summary>
		/// <param name="uid">The server side uid that identifies the enumerator.</param>
		[OperationContract]
		void OnEnumeratorReset(Guid uid);

		/// <summary>
		/// Invoked to create a new server side exectutor.
		/// </summary>
		/// <param name="text">The text of the command to be executed by the new exectutor.</param>
		/// <param name="pars">the list of parameters to be used to execute the command of the new exectutor.</param>
		[OperationContract]
		Guid OnExecutorCreate(string text, IKParameterCollection pars);

		/// <summary>
		/// Invoked to dispose the server side executor.
		/// </summary>
		/// <param name="uid">The server side uid that identifies the executor.</param>
		[OperationContract]
		void OnExecutorDispose(Guid uid);

		/// <summary>
		/// Invoked to execute the server side executor, returning an integer that typically represents the number
		/// of records that were affected by the command, among other possible meanings.
		/// </summary>
		/// <param name="uid">The server side uid that identifies the executor.</param>
		[OperationContract]
		int OnExecutorExecute(Guid uid);
	}
}
// ======================================================== 

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