/// <summary>
        /// Retrieves list of Lookup objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of Lookup objects</returns>
        private LookupList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //Lookup list
            LookupList list = new LookupList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    Lookup lookupObject = new Lookup();
                    FillObject(lookupObject, reader);

                    list.Add(lookupObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
Esempio n. 2
0
 private void FillBuffer(TSourceOutput sourceRow)
 {
     if (LookupList == null)
     {
         LookupList = new List <TSourceOutput>();
     }
     LookupList.Add(sourceRow);
 }
        public void LookupList_key_indexer_returns_value()
        {
            var list = new LookupList<string, Item>(x => x.Name);
            var item = new Item {Name = "key", Value = 12};
            list.Add(item);

            list["key"].Should().Be(item);
        }
Esempio n. 4
0
        private Package UsePackage(string packageName)
        {
            var packageDir = Context.FindPackageDir(packageName);

            if (!Packages.TryGetValue(packageDir, out var package))
            {
                package = new Package(Context, packageDir, packageName);
                Packages.Add(packageDir, package);
            }

            return(package);
        }
Esempio n. 5
0
        public void AddMapping(T tObj, U uObj)
        {
            // TODO: remove this code once the error is resolved.
            if (tObj == null)
            {
                throw new Exception("tObj is null.");
            }

            if (uObj == null)
            {
                throw new Exception("uObj is null.");
            }

            if (tLookup == null)
            {
                throw new Exception("tLookup is null.");
            }

            if (uLookup == null)
            {
                throw new Exception("uLookup is null.");
            }

            if (uObj.InternalIdentifier == null)
            {
                throw new Exception("uObj.InternalIdentifier is null.");
            }

            if (tObj.InternalIdentifier == null)
            {
                throw new Exception("tObj.InternalIdentifier is null.");
            }

            tLookup[uObj.InternalIdentifier] = tObj;
            uLookup.Add(tObj.InternalIdentifier, uObj);
        }