All pastes #454116 Raw Edit

Something

public text v1 · immutable
·published 2007-04-23 12:43 UTC
rendered paste body
public static com.janoserdelyi.nagry.DataObjects.Article Select (
		int articleId
	) {
		System.Data.IDbConnection conn = null;
		System.Data.IDataReader dr = null;
		
		try {
			conn = com.janoserdelyi.DataSource.ConnectionManager.GetConnection("Nagry");
			
			Npgsql.NpgsqlCommand command = new NpgsqlCommand("select * from article where article_id = :articleId and active = true;", (Npgsql.NpgsqlConnection)conn);
	    
			com.janoserdelyi.DataSource.CommandHelperFactory chf = new com.janoserdelyi.DataSource.CommandHelperFactory(DataSource.DatabaseType.Postgresql);
			com.janoserdelyi.DataSource.ICommandHelper commandHelper = chf.GetHelper();
			commandHelper.Command = command;
			
			commandHelper.Append("articleId", articleId);
			
			dr = command.ExecuteReader();
			
			com.janoserdelyi.DataSource.PostgresqlDataReaderHelper drh = new com.janoserdelyi.DataSource.PostgresqlDataReaderHelper();
			drh.DataReader = dr;
			
			com.janoserdelyi.nagry.DataObjects.Article ret = null;
			
			if (dr.Read()) {
				ret = new com.janoserdelyi.nagry.DataObjects.Article(
					drh.GetInt("article_id"), 
					drh.GetString("article_title"), 
					drh.GetString("article_desc"),
					drh.GetString("article_content"), 
					drh.GetBool("active"), 
					drh.GetDateTime("publish_dt"),
					drh.GetDateTimeObj("expire_dt"), 
					drh.GetBool("allow_comments"), 
					drh.GetDateTime("create_dt"), 
					drh.GetInt("create_author_id"), 
					drh.GetInt("edit_count"), 
					drh.GetIntObj("edit_author_id"),
					drh.GetInt("categories")
				);
			}
			return ret;
		} catch (Npgsql.NpgsqlException) {
			throw;
		} catch (System.Exception) {
			throw;
		} finally {
			try {
				com.janoserdelyi.DataSource.ConnectionManager.Close(conn);
			} catch {}
		}
	}