public IEnumerable<IOnlineRecord> GetUnmatchedRecords() { List<IOnlineRecord> records = new List<IOnlineRecord>(); SqlDataReader data = ExecuteReader( "SELECT * FROM [{0}] WHERE LineItemID=0", recordTemplate.TableName ); try { while( data.Read() ) { SqlRecord record = new SqlRecord(); record.SetSaved( true ); record.Fill( data ); records.Add( record as IOnlineRecord ); } } finally { data.Close(); } return records; }
public IOnlineRecord FindRecord( IOnlineRecord record ) { // CREATE UNIQUE NONCLUSTERED INDEX [IDX_Unique] ON [dbo].[Record] // ( [Source], [Description], [PostDate], [Amount], [BankId], [Number] ); SqlRecord foundRecord = new SqlRecord(); foundRecord.OnlineSource = record.OnlineSource; foundRecord.BankId = record.BankId; foundRecord.Date = record.Date; foundRecord.Description = record.Description; foundRecord.Amount = record.Amount; foundRecord.Number = record.Number; foundRecord.SetParameters( command.Parameters ); foundRecord.FillParameters( command.Parameters ); SqlDataReader data = ExecuteReader( "SELECT ID, LineItemID FROM [{0}] WHERE [Source]=@source AND [Description]=@description AND [PostDate]=@date AND [Amount]=@amount AND [BankId]=@bankId AND [Number]=@number", recordTemplate.TableName ); try { if( data.Read() ) { foundRecord.SetSaved( true ); foundRecord.Id = Convert.ToInt32( data["ID"] ); foundRecord.LineItemId = Convert.ToInt32( data["LineItemID"] ); } else { // No record found in the database. foundRecord = null; } } finally { data.Close(); } return foundRecord; }