Exemplo n.º 1
0
 public int GetSpecificWordRow(string manufacturer, string keywords)
 {
     using (DefaultConnection db = new DefaultConnection())
     {
         SQLWhereString whereString = new SQLWhereString();
         string where = whereString.SearchKeyWhere <ReadableProduct>(db, keywords);
         int openManufacturer_Id  = ManufacturerData.NameToId(db, manufacturer)[0];
         int closeManufacturer_Id = ManufacturerData.NameToId(db, manufacturer)[1];
         if (!String.IsNullOrEmpty(keywords))
         {
             var anonymous = db.Database
                             .SqlQuery <ReadableProduct>(where)
                             .ToList();
             return(anonymous
                    .Where(a => a.Manufacturer_Id >= openManufacturer_Id &&
                           a.Manufacturer_Id <= closeManufacturer_Id)
                    .Count());
         }
         else
         {
             return(db.ReadableProducts
                    .Where(rp => rp.Manufacturer_Id >= openManufacturer_Id &&
                           rp.Manufacturer_Id <= closeManufacturer_Id)
                    .Count());
         }
     }
 }
Exemplo n.º 2
0
        public List <ReadableProductAttribute> GetSpecificWordGroup(string businessPartner, string manufacturer, string keywords)
        {
            using (DefaultConnection db = new DefaultConnection())
            {
                SQLWhereString whereString = new SQLWhereString();
                string where = whereString.SearchKeyWhere <ReadableProductAttribute>(db, keywords);
                int openManufacturer_Id     = ManufacturerData.NameToId(db, manufacturer)[0];
                int closeManufacturer_Id    = ManufacturerData.NameToId(db, manufacturer)[1];
                int openBusinessPertner_Id  = BusinessPartnerData.NameToId(db, businessPartner)[0];
                int closeBusinessPertner_Id = BusinessPartnerData.NameToId(db, businessPartner)[1];
                if (!String.IsNullOrEmpty(keywords))
                {
                    var anonymous = db.Database
                                    .SqlQuery <ReadableProductAttribute>(where)
                                    .ToList();

                    return(anonymous
                           .Where(a => a.Manufacturer_Id >= openManufacturer_Id &&
                                  a.Manufacturer_Id <= closeManufacturer_Id &&
                                  a.BusinessPartner_Id >= openBusinessPertner_Id &&
                                  a.BusinessPartner_Id <= closeBusinessPertner_Id)
                           .ToList());
                }
                else
                {
                    return(db.ReadableProductAttributes
                           .Where(ra => ra.Manufacturer_Id >= openManufacturer_Id &&
                                  ra.Manufacturer_Id <= closeManufacturer_Id &&
                                  ra.BusinessPartner_Id >= openBusinessPertner_Id &&
                                  ra.BusinessPartner_Id <= closeBusinessPertner_Id)
                           .ToList());
                }
            }
        }