Click here to Skip to main content
15,884,298 members
Articles / Database Development / SQL Server

.NET Installer that automatically installs MSDE

Rate me:
Please Sign up or sign in to vote.
3.63/5 (7 votes)
26 Jul 2008GPL36 min read 45.4K   557   30  
This project enables developers to create a setup package that automatically installs MSDE and attaches database
										#region MasterHistoryModuleExtend
										public string GetMasterHistory{Table}SQLEntityCollectionLatestDate()
										{
											string _sql = @"select b.* FROM
															(
																select " + {RecordIDColumn} + @", MAX(" + {EffectiveDateColumn} + ") as EffectiveDate from {Table} GROUP BY " + {RecordIDColumn} + @"
															) a
															LEFT JOIN
																{Table} b
															ON a." + {RecordIDColumn} + @" = b." + {RecordIDColumn} + @" AND a." + {EffectiveDateColumn} + @" = b." + {EffectiveDateColumn} + "";
											return _sql;
										}
										
										public string GetMasterHistory{Table}SQLEntityLatestDateByRecordID(object _value, ref IDbDataParameter[] _params)
										{
											string _sql = "SELECT TOP 1 * FROM {Table} WHERE " + {RecordIDColumn} + "=@HistoryParam1 ORDER BY " + {EffectiveDateColumn} + " DESC";
											
											_params = new IDbDataParameter[1];
											_params[0] = Filler.Definition.DALLayer.GetCommand().CreateParameter();
											_params[0].ParameterName = "@HistoryParam1";
											_params[0].Value = _value;
											
											return _sql;
										}
										
										public string GetMasterHistory{Table}SQLEntityCollectionByEffectiveDate(DateTime _effectiveDate, ref IDbDataParameter[] _params)
										{
											string _sql = @"select b.* FROM
															(
																select " + {RecordIDColumn} + @", MAX(" + {EffectiveDateColumn} + ") as EffectiveDate from {Table} WHERE " + {EffectiveDateColumn} + "<=@HistoryCollectionParam1 GROUP BY " + {RecordIDColumn} + @"
															) a
															LEFT JOIN
																{Table} b
															ON a." + {RecordIDColumn} + @" = b." + {RecordIDColumn} + @" AND a." + {EffectiveDateColumn} + @" = b." + {EffectiveDateColumn} + "";
											
											_params = new IDbDataParameter[1];
											_params[0] = Filler.Definition.DALLayer.GetCommand().CreateParameter();
											_params[0].ParameterName = "@HistoryCollectionParam1";
											_params[0].Value = _effectiveDate;
											
											return _sql;
										}
										
										public string GetMasterHistory{Table}SQLEntityLatestDateByRecordIDEffectiveDate(object _value, DateTime _effectiveDate, ref IDbDataParameter[] _params)
										{
											string _sql = "SELECT TOP 1 * FROM {Table} WHERE " + {RecordIDColumn} + "=@HistoryParam1 AND " + {EffectiveDateColumn} + "<=@HistoryParam2 ORDER BY " + {EffectiveDateColumn} + " DESC";
											
											_params = new IDbDataParameter[2];
											_params[0] = Filler.Definition.DALLayer.GetCommand().CreateParameter();
											_params[0].ParameterName = "@HistoryParam1";
											_params[0].Value = _value;
											_params[1] = Filler.Definition.DALLayer.GetCommand().CreateParameter();
											_params[1].ParameterName = "@HistoryParam2";
											_params[1].Value = _effectiveDate;
											
											return _sql;
										}
										
										public {Table}Entity GetMasterHistory{Table}EntityLatestDateByRecordID(object _value)
										{
											{Table}EntityCollection _collection = new {Table}EntityCollection();
											
											IDbDataParameter[] _params = null;
											string _sql = GetMasterHistory{Table}SQLEntityLatestDateByRecordID(_value, ref _params);
											_collection.GetDataByManual(_sql, _params);
											
											if (_collection.Collection.Count > 0) return _collection[0];
											return null;
										}
										
										public {Table}EntityCollection GetMasterHistory{Table}EntityCollectionLatestDate()
										{
											{Table}EntityCollection _collection = new {Table}EntityCollection();
											string _sql = GetMasterHistory{Table}SQLEntityCollectionLatestDate();
											_collection.GetDataByManual(_sql, null);
										
											return _collection;	
										}
										
										public {Table}Entity GetMasterHistory{Table}EntityByRecordIDEffectiveDate(object _value, DateTime _effectiveDate)
										{
											{Table}EntityCollection _collection = new {Table}EntityCollection();
											
											IDbDataParameter[] _params = null;
											string _sql = GetMasterHistory{Table}SQLEntityLatestDateByRecordIDEffectiveDate(_value, _effectiveDate, ref _params);
											_collection.GetDataByManual(_sql, _params);
											
											if (_collection.Collection.Count > 0) return _collection[0];
											return null;
										}
										
										public {Table}EntityCollection GetMasterHistory{Table}EntityCollectionByDate(DateTime _effectiveDate)
										{
											{Table}EntityCollection _collection = new {Table}EntityCollection();
											
											IDbDataParameter[] _params = null;
											string _sql = GetMasterHistory{Table}SQLEntityCollectionByEffectiveDate(_effectiveDate, ref _params);
											_collection.GetDataByManual(_sql, _params);
										
											return _collection;	
										}
										#endregion

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 GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
Singapore Singapore
I write code mostly in C#, VB.NET, PHP and Assembly.

Comments and Discussions