Click here to Skip to main content
15,886,026 members
Articles / Programming Languages / C#

Data Access and Transaction Handling Framework

Rate me:
Please Sign up or sign in to vote.
4.69/5 (107 votes)
13 Jan 200510 min read 917.7K   2.1K   282  
Generic data access component for different datasources, sprocs/SQL, implicitly propagated transactions, explicitly managed transaction contexts etc.
<?xml version="1.0" encoding="utf-8" ?> 
<dataOperations dataSource="DataSource1" xmlns="Framework.DataAccess">
	<dataCommands>
		<dataCommand name="SelectUsersCommand1" type="Text">
			<commandText><![CDATA[
				SELECT 
					COUNT(*) 
				FROM Users AS U1
				WHERE 1=1
				{1}
			]]></commandText>
			<replaceByParamValues>
				<replaceByParamValue paramName="@UserID" paramValue="DBNull.Value">
					<oldString>{1}</oldString>
					<newString></newString>
					<defaultString><![CDATA[AND U1.UserID < @UserID]]></defaultString>
				</replaceByParamValue>
			</replaceByParamValues>
			<parameters>
				<param name="@UserID" type="Int" direction="Input" />
			</parameters>			
		</dataCommand>
		
		<dataCommand name="SelectUsersCommand2" type="Text">
			<commandText><![CDATA[
				SELECT 
					COUNT(*)
				FROM Users AS U1
				WHERE 1=1
				AND U1.UserID < @UserID
			]]></commandText>
			<replaceByParamValues>
				<replaceByParamValue paramName="@UserID" paramValue="DBNull.Value">
					<oldString><![CDATA[AND U1.UserID < @UserID]]></oldString>
					<newString></newString>
				</replaceByParamValue>
			</replaceByParamValues>
			<parameters>
				<param name="@UserID" type="Int" direction="Input" />
			</parameters>			
		</dataCommand>
		
	</dataCommands>
</dataOperations>

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions