ADO.NET Provider for Stripe

Build 21.0.7930

Code-First Approach

An alternative to introspecting the model from the provider is to handwrite your model classes. This is the code-first approach to Entity Framework, which gives you greater control over the exact data model you use in your application.

Install Entity Framework

Install Entity Framework or add references to the required assemblies for your chosen version of Entity Framework. See Using EF 6 for using Entity Framework 6. See Installed Assemblies for more information about all assemblies shipped with the provider.

Register the Provider

Add the connection string to App.Config or Web.config. The connectionStrings node is often located directly below the configSection node in the root configuration node.

    <add name="StripeContext" connectionString="InitiateOAuth=GETANDREFRESH;OAuthClientId=MyClientId;OAuthClientSecret=MyClientSecret;CallbackURL=http://localhost:33333;" providerName="System.Data.CData.Stripe" />

Create the Context Class

Start by creating the StripeContext class. This is the base object that extends DbContext and exposes the DbSet properties that represent the tables in the data source. Next, override some of the default functionality of the DbContext class by overriding the OnModelCreating method. You can find a description of these properties in the code below:

using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;

class StripeContext : DbContext {
  public StripeContext() { }

  public DbSet<Customers> Customers { set; get; }
  protected override void OnModelCreating(DbModelBuilder modelBuilder)
    // To remove the requests to the Migration History table
    // To remove the plural names
    //For versions of EF before 6.0, uncomment the following line to remove calls to EdmTable, a metadata table

Create the Table Models

Finally, define a class for each table that was defined in the DbSet properties of the context class. The table classes should have a list of properties that correspond to each field of that table. A corresponding map class must be defined to configure attributes for each property in the table class.

using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema; //EF 6 and later
//using System.ComponentModel.DataAnnotations //For versions of EF before 6

public class Customers  {
  public System.String Id { get; set; }
  public System.String Email { get; set; }

Perform LINQ Commands in Your Code

You are now ready to start using LINQ in your code. Be sure to declare "using System.Linq" in your file.

StripeContext ents = new StripeContext();
var CustomersQuery = from Customers in ents.Customers
                   orderby Customers.Email
                   select Customers;

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930