/// <summary> /// Get Product Identifier /// links: /// docLink: http://sql2x.org/documentationLink/06760f02-f3ec-45ad-bbfe-db43d7a0378f /// </summary> /// <template>DotNetFrameworkWithDurian</template> /// <cardinality>Many</cardinality> public List <ProductMaintenanceIdentifierIndexWithFilterData> ProductMaintenanceIdentifierIndexWithFilter( System.Guid productId ) { var ret = new List <ProductMaintenanceIdentifierIndexWithFilterData>(); string sql = @" select [p].product_name ,[pir].product_identifier_name ,[du].default_user_name ,[p].state_rcd ,[pi].product_id ,[pi].product_identifier_rcd ,[pi].identifier ,[pi].user_id ,[pi].date_time ,[pi].product_identifier_id from product_identifier as [pi] inner join product as [p] on [p].product_id = [pi].product_id inner join product_identifier_ref as [pir] on [pir].product_identifier_rcd = [pi].product_identifier_rcd inner join default_user as [du] on [du].default_user_id = [pi].user_id where 1 = 1 "; using (var conn = new SqlConnection(ConfigurationManager.AppSettings["Conn"])) { conn.Open(); using (var command = new SqlCommand(sql, conn)) { if (productId != Guid.Empty) { command.Parameters.Add("@product_id", SqlDbType.UniqueIdentifier).Value = (System.Guid)productId; sql += " and [pi].product_id = @product_id"; } command.CommandText = sql; // Logging log = Logging.PerformanceTimeStart("ProductMaintenanceIdentifierIndexWithFilter"); IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult); // log.PerformanceTimeStop(sql, command); var ordinals = new ProductMaintenanceIdentifierIndexWithFilterDataOrdinals(reader); while (reader.Read()) { var data = new ProductMaintenanceIdentifierIndexWithFilterData(); data.Populate(reader, ordinals); ret.Add(data); } reader.Close(); } return(ret); } }
// use ordinals to speed up access to DataReader // links: // docLink: http://sql2x.org/documentationLink/327451c3-64a8-4de8-b359-76742d634497 // parameters: // reader: IDataReader from SQLClient public void Populate(IDataReader reader, ProductMaintenanceIdentifierIndexWithFilterDataOrdinals ordinals) { if (!reader.IsDBNull(ordinals.ProductName)) { ProductName = reader.GetString(ordinals.ProductName); } if (!reader.IsDBNull(ordinals.ProductIdentifierName)) { ProductIdentifierName = reader.GetString(ordinals.ProductIdentifierName); } if (!reader.IsDBNull(ordinals.DefaultUserName)) { DefaultUserName = reader.GetString(ordinals.DefaultUserName); } if (!reader.IsDBNull(ordinals.StateRcd)) { StateRcd = reader.GetString(ordinals.StateRcd); } if (!reader.IsDBNull(ordinals.ProductId)) { ProductId = reader.GetGuid(ordinals.ProductId); } if (!reader.IsDBNull(ordinals.ProductIdentifierRcd)) { ProductIdentifierRcd = reader.GetString(ordinals.ProductIdentifierRcd); } if (!reader.IsDBNull(ordinals.Identifier)) { Identifier = reader.GetString(ordinals.Identifier); } if (!reader.IsDBNull(ordinals.UserId)) { UserId = reader.GetGuid(ordinals.UserId); } if (!reader.IsDBNull(ordinals.DateTime)) { DateTime = reader.GetDateTime(ordinals.DateTime); } if (!reader.IsDBNull(ordinals.ProductIdentifierId)) { ProductIdentifierId = reader.GetGuid(ordinals.ProductIdentifierId); } }