private IEnumerable <SqlDataRecord> ToSqlDataRecords(IEnumerable <Flight> items)
        {
            // Construct the Data Record with the MetaData:
            SqlDataRecord sdr = new SqlDataRecord(
                new SqlMetaData("Year", SqlDbType.Int),
                new SqlMetaData("Month", SqlDbType.Int),
                new SqlMetaData("DayOfMonth", SqlDbType.Int),
                new SqlMetaData("DayOfWeek", SqlDbType.Int),
                new SqlMetaData("FlightDate", SqlDbType.DateTime2),
                new SqlMetaData("UniqueCarrier", SqlDbType.NVarChar, 55),
                new SqlMetaData("TailNumber", SqlDbType.NVarChar, 55),
                new SqlMetaData("FlightNumber", SqlDbType.NVarChar, 55),
                new SqlMetaData("OriginAirport", SqlDbType.NVarChar, 55),
                new SqlMetaData("OriginState", SqlDbType.NVarChar, 55),
                new SqlMetaData("DestinationAirport", SqlDbType.NVarChar, 55),
                new SqlMetaData("DestinationState", SqlDbType.NVarChar, 55),
                new SqlMetaData("DepartureDelay", SqlDbType.Int),
                new SqlMetaData("TaxiOut", SqlDbType.Int),
                new SqlMetaData("TaxiIn", SqlDbType.Int),
                new SqlMetaData("ArrivalDelay", SqlDbType.Int),
                new SqlMetaData("CancellationCode", SqlDbType.NVarChar, 55),
                new SqlMetaData("CarrierDelay", SqlDbType.Int),
                new SqlMetaData("WeatherDelay", SqlDbType.Int),
                new SqlMetaData("NasDelay", SqlDbType.Int),
                new SqlMetaData("SecurityDelay", SqlDbType.Int),
                new SqlMetaData("LateAircraftDelay", SqlDbType.Int)
                );

            // Now yield the Measurements in the Data Record:
            foreach (var item in items)
            {
                sdr.SetInt32(0, item.Year);
                sdr.SetInt32(1, item.Month);
                sdr.SetInt32(2, item.DayOfMonth);
                sdr.SetInt32(3, item.DayOfWeek);
                sdr.SetDateTime(4, item.FlightDate);
                sdr.SetString(5, item.UniqueCarrier);
                sdr.SetString(6, item.TailNumber);
                sdr.SetString(7, item.FlightNumber);
                sdr.SetString(8, item.OriginAirport);
                sdr.SetString(9, item.OriginState);
                sdr.SetString(10, item.DestinationAirport);
                sdr.SetString(11, item.DestinationState);
                sdr.SetNullableInt32(12, item.DepartureDelay);
                sdr.SetNullableInt32(13, item.TaxiOut);
                sdr.SetNullableInt32(14, item.TaxiIn);
                sdr.SetNullableInt32(15, item.ArrivalDelay);
                sdr.SetString(16, item.CancellationCode);
                sdr.SetNullableInt32(17, item.CarrierDelay);
                sdr.SetNullableInt32(18, item.WeatherDelay);
                sdr.SetNullableInt32(19, item.NasDelay);
                sdr.SetNullableInt32(20, item.SecurityDelay);
                sdr.SetNullableInt32(21, item.LateAircraftDelay);

                yield return(sdr);
            }
        }
Exemplo n.º 2
0
        IEnumerator <SqlDataRecord> IEnumerable <SqlDataRecord> .GetEnumerator()
        {
            var sdr = new SqlDataRecord(
                new[] {
                new SqlMetaData("ID", SqlDbType.VarChar, 36),
                new SqlMetaData("FESAUSERID", SqlDbType.VarChar, 36),
                new SqlMetaData("NAME", SqlDbType.VarChar, 100),
                new SqlMetaData("EMAIL", SqlDbType.VarChar, 100),
                new SqlMetaData("PHONE", SqlDbType.VarChar, 9),
                new SqlMetaData("USERNAME", SqlDbType.VarChar, 50),
                new SqlMetaData("PASSWORD", SqlDbType.VarChar, 200),
                new SqlMetaData("PHOTO", SqlDbType.VarChar, 200),
                new SqlMetaData("USERTYPE", SqlDbType.Int),
                new SqlMetaData("USERSTATUS", SqlDbType.Int),
                new SqlMetaData("ROLEID", SqlDbType.VarChar, 36),
                new SqlMetaData("OFFICEID", SqlDbType.Int),
                new SqlMetaData("COSTCENTERID", SqlDbType.Int),
                new SqlMetaData("CELULLAR", SqlDbType.VarChar, 50),
                new SqlMetaData("RPM", SqlDbType.VarChar, 50)
            }
                );

            foreach (var usrRow in this)
            {
                sdr.SetNullableString(0, usrRow.Id);
                sdr.SetNullableString(1, usrRow.FesaUserId);
                sdr.SetNullableString(2, usrRow.Name);
                sdr.SetNullableString(3, usrRow.Email);
                sdr.SetNullableString(4, usrRow.Phone);
                sdr.SetNullableString(5, usrRow.UserName);
                sdr.SetNullableString(6, usrRow.Password);
                sdr.SetNullableString(7, usrRow.Photo);
                sdr.SetNullableInt32(8, (int)usrRow.UserType);
                sdr.SetNullableInt32(9, (int)usrRow.UserStatus);
                sdr.SetNullableString(10, usrRow.Role.Id);
                sdr.SetNullableInt32(11, usrRow.OfficeId);
                sdr.SetNullableInt32(12, usrRow.CostCenterId);
                sdr.SetNullableString(13, usrRow.Celullar);
                sdr.SetNullableString(14, usrRow.Rpm);
                yield return(sdr);
            }
        }