private void DataPortal_Fetch(PKCriteria criteria) { Database.LogInfo("Supplier.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.Northwind_SqlConnection) { ApplicationContext.LocalContext["cn"] = cn; using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getSupplier"; cm.Parameters.AddWithValue("@SupplierID", criteria.SupplierID); using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { if (!dr.Read()) { _ErrorMessage = "No Record Found"; return; } ReadData(dr); // load child objects dr.NextResult(); _SupplierProducts = SupplierProducts.Get(dr); } } // removing of item only needed for local data portal if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) { ApplicationContext.LocalContext.Remove("cn"); } } } catch (Exception ex) { Database.LogException("Supplier.DataPortal_Fetch", ex); _ErrorMessage = ex.Message; throw new DbCslaException("Supplier.DataPortal_Fetch", ex); } }
public SupplierProductsPropertyDescriptor(SupplierProducts collection, int index) : base(collection, index) { ; }