public List <CreditNote> GETCNSID() { DataSet ds = new DataSet(); DBHelper db = new DBHelper(); List <CreditNote> CNs = new List <CreditNote>(); if (conn.State == System.Data.ConnectionState.Closed) { try { conn.Open(); } catch (Exception ex) { log.Error("Cannot open the Database due to: ", ex); return(null); } } try { using (SqlCommand cmd = new SqlCommand("spr_GetDataSAPPI", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 300; SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); cmd.ExecuteNonQuery(); conn.Close(); } DataTable CreNote = ds.Tables[0]; CNs = CreNote.AsEnumerable(). Select(CN => new CreditNote { InterfaceType = CN.Field <string>("INTERFACETYPE"), SalesOrg = CN.Field <string>("SALESORG"), SoldtoParty = CN.Field <string>("SOLDTOPARTY"), ShiptoParty = CN.Field <string>("SHIPTOPARTY"), OrderReason = CN.Field <string>("ORDERREASON"), OrderDate = CN.Field <DateTime>("ORDERDATE").ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture), RequestDeliveryDate = CN.Field <DateTime>("REQUESTDELIVERYDATE").ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture), CustomerDocument = CN.Field <string>("CUSTOMERDOCUMENT"), MaterialNumber = CN.Field <string>("MATERIALNUMBER"), OrderQuantity = CN.Field <decimal>("ORDERQUANTITY").ToString(), SalesUnit = CN.Field <string>("SALESUNIT"), ConditionalType = CN.Field <string>("CONDITIONTYPE"), Amount = CN.Field <Decimal>("AMOUNT").ToString(), IONumber = CN.Field <string>("IONUMBER"), GUI = CN.Field <string>("GUI") }).ToList(); log.Info("Get CreditNotes successfull total record: " + CreNote.Rows.Count); return(CNs); } catch (Exception ex) { log.Error("Cannot get CreditNotes due to: ", ex); return(null); } }