示例#1
0
 // use ordinals to speed up access to DataReader
 // links:
 //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
 //  docLink: http://sql2x.org/documentationLink/327451c3-64a8-4de8-b359-76742d634497
 // parameters:
 //  reader: IDataReader from SQLClient
 public void Populate(IDataReader reader, GetDefaultChangeLogDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.DefaultChangeName))
     {
         DefaultChangeName = reader.GetString(ordinals.DefaultChangeName);
     }
     if (!reader.IsDBNull(ordinals.DefaultChangeDescription))
     {
         DefaultChangeDescription = reader.GetString(ordinals.DefaultChangeDescription);
     }
     if (!reader.IsDBNull(ordinals.DateTime))
     {
         DateTime = reader.GetDateTime(ordinals.DateTime);
     }
     if (!reader.IsDBNull(ordinals.DefaultChangeLogTypeRcd))
     {
         DefaultChangeLogTypeRcd = reader.GetString(ordinals.DefaultChangeLogTypeRcd);
     }
     if (!reader.IsDBNull(ordinals.DefaultChangeLogTypeName))
     {
         DefaultChangeLogTypeName = reader.GetString(ordinals.DefaultChangeLogTypeName);
     }
     if (!reader.IsDBNull(ordinals.DefaultIssueId))
     {
         DefaultIssueId = reader.GetGuid(ordinals.DefaultIssueId);
     }
     if (!reader.IsDBNull(ordinals.IssueName))
     {
         IssueName = reader.GetString(ordinals.IssueName);
     }
     if (!reader.IsDBNull(ordinals.DefaultChangeLogId))
     {
         DefaultChangeLogId = reader.GetGuid(ordinals.DefaultChangeLogId);
     }
 }
示例#2
0
        /// <summary>Get Default Change Log</summary>
        /// <cardinality>Many</cardinality>
        public List <GetDefaultChangeLogData> GetDefaultChangeLog(
            System.String defaultChangeName
            , System.String defaultChangeLogTypeRcd
            , System.Guid defaultIssueId
            , System.Guid defaultChangeLogId
            )
        {
            var    ret = new List <GetDefaultChangeLogData>();
            string sql = @"select
     dcl.default_change_name
    ,dcl.default_change_description
    ,dcl.date_time
    ,dcl.default_change_log_type_rcd
    ,dcltr.default_change_log_type_name
    ,dcl.default_issue_id
    ,di.issue_name as issue_name
    ,dcl.default_change_log_id
from default_change_log as dcl
inner join default_change_log_type_ref as dcltr on dcltr.default_change_log_type_rcd = dcl.default_change_log_type_rcd
left join default_issue as di on di.default_issue_id = dcl.default_issue_id
where 1 = 1
";

            using (var conn = new SqlConnection(Conn.ConnectionString)) {
                conn.Open();

                using (var command = new SqlCommand(sql, conn)) {
                    if (!String.IsNullOrEmpty(defaultChangeName))
                    {
                        command.Parameters.Add("@default_change_name", SqlDbType.NVarChar).Value = (System.String)defaultChangeName;
                        sql += " and dcl.default_change_name = @default_change_name";
                    }
                    if (!String.IsNullOrEmpty(defaultChangeLogTypeRcd))
                    {
                        command.Parameters.Add("@default_change_log_type_rcd", SqlDbType.NVarChar).Value = (System.String)defaultChangeLogTypeRcd;
                        sql += " and dcl.default_change_log_type_rcd = @default_change_log_type_rcd";
                    }
                    if (defaultIssueId != Guid.Empty)
                    {
                        command.Parameters.Add("@default_issue_id", SqlDbType.UniqueIdentifier).Value = (System.Guid)defaultIssueId;
                        sql += " and dcl.default_issue_id = @default_issue_id";
                    }
                    if (defaultChangeLogId != Guid.Empty)
                    {
                        command.Parameters.Add("@default_change_log_id", SqlDbType.UniqueIdentifier).Value = (System.Guid)defaultChangeLogId;
                        sql += " and dcl.default_change_log_id = @default_change_log_id";
                    }

                    Logging     log    = Logging.PerformanceTimeStart("GetDefaultChangeLog");
                    IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                    log.PerformanceTimeStop(sql, command);

                    var ordinals = new GetDefaultChangeLogDataOrdinals(reader);

                    while (reader.Read())
                    {
                        var data = new GetDefaultChangeLogData();
                        data.Populate(reader, ordinals);
                        ret.Add(data);
                    }

                    reader.Close();
                }

                return(ret);
            }
        }