I am not sure I am getting the correct definition for what API Usage is. I have a snippet of code that is used for a BulkInsert into SQL from c# application. It said the snippet shows the API usage. How do I translate that?
private void WriteToDatabase() { // get your connection string string connString = ''; // connect to SQL using (SqlConnection connection = new SqlConnection(connString)) { // make sure to enable triggers // more on triggers in next post SqlBulkCopy bulkCopy = new SqlBulkCopy ( connection, SqlBulkCopyOptions.TableLock | SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.UseInternalTransaction, null ); // set the destination table name bulkCopy.DestinationTableName = this.tableName; connection.Open(); // write the data in the 'dataTable' bulkCopy.WriteToServer(dataTable); connection.Close(); } // reset this.dataTable.Clear(); this.recordCount = 0; }
An application programming interface (API) is a set of routines, data structures, object classes and/or protocols provided by libraries and/or operating system services in order to support the building of applications
In simpler terms, an API consists of the bits of an assembly you can see and interact with from the outside. The Microsoft.NET framework has LOTS of stuff that you can’t use because they are not part of the framework’s API. These classes, methods, interfaces, etc are marked internal or private, and are intended for use by MS.
What you’re looking at is just an example of using this code from the perspective of someone on the outside of the library looking in. In other words, you could have written this code yourself, as a consumer of the API. It doesn’t detail all the possible ways to use the API, but it gives you a hint.