Пример #1
0
        /// <summary>
        /// Executes query that might return multiple records, but only takes 1st one.
        /// </summary>
        static Company GetFirstCompany(ColumnConstructorParameterMappingCollection <Company> ctorMappings, IEnumerable <PropertyColumnMapping> propMappings)
        {
            string sql = "SELECT * FROM Company WHERE RegistryNumber LIKE '788%';";

            var settings = new SqlCommandSettings(sql, CommandType.Text);

            var executor = new SqlExecutor(cs);

            var company = executor.GetFirstRecord <Company>(settings, ctorMappings, propMappings);

            return(company);
        }
Пример #2
0
        /// <summary>
        /// Executes query that might return multiple records, but only takes 1st one.
        /// </summary>
        static Person GetFirstPerson(IEnumerable <PropertyColumnMapping> mappings)
        {
            string sql = "SELECT * FROM Person WHERE LastName = @lastName;";

            var settings = new SqlCommandSettings(sql, CommandType.Text);

            settings.AddParameter(new SqlParameter("@lastName", "Mouse"));

            var executor = new SqlExecutor(cs);

            var person = executor.GetFirstRecord <Person>(settings, mappings);

            return(person);
        }