ノーコードでクラウド上のデータとの連携を実現。
詳細はこちら →無償トライアル:
無償トライアルへ製品の情報と無償トライアルへ:
Xero WorkflowMax に連携する.NET アプリケーションを素早く、簡単に開発できる便利なドライバー。
加藤龍彦
ウェブデベロッパー
ADO.NET Adapter
Entity Framework はobject-relational mapping フレームワークで、データをオブジェクトとして扱うために使われます。Visual Studio のADO.NET Entity Data Model ウィザードを実行するとEntity Model を作成できますが、このモデルファーストアプローチでは、データソースに変更があった場合やエンティティ操作をより制御したい場合は不都合があります。この記事では、CData ADO.NET Provider を使いコードファーストアプローチでXero WorkflowMax にアクセスします。
WorkflowMax API に接続するには、Xero からAPIKey とAccountKey を取得します。取得については、 Xero のサポートにお問い合わせ頂く必要があります。(https://www.workflowmax.com/contact-us).
API キーとAccount キーを取得したら、APIKey とAccountKey 接続プロパティの値を設定してください。 これらが設定されれば、接続の準備は完了です。
<configuration>
... <connectionStrings>
<add name="XeroWorkflowMaxContext" connectionString="Offline=False;APIKey=myApiKey;AccountKey=myAccountKey;" providerName="System.Data.CData.XeroWorkflowMax" />
</connectionStrings>
<entityFramework>
<providers>
... <provider invariantName="System.Data.CData.XeroWorkflowMax" type="System.Data.CData.XeroWorkflowMax.XeroWorkflowMaxProviderServices, System.Data.CData.XeroWorkflowMax.Entities.EF6" />
</providers>
<entityFramework>
</configuration>
</code>
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.ModelConfiguration.Conventions;
class XeroWorkflowMaxContext :DbContext {
public XeroWorkflowMaxContext() { }
protected override void OnModelCreating(DbModelBuilder modelBuilder) { // To remove the requests to the Migration History table
Database.SetInitializer<XeroWorkflowMaxContext>(null); // To remove the plural names modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
}
}
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;
public class Clients {
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public System.String Id { get; set; }
public System.String Id { get; set; }
}
public class ClientsMap :EntityTypeConfiguration<Clients> {
public ClientsMap() {
this.ToTable("Clients");
this.HasKey(Clients => Clients.Id);
this.Property(Clients => Clients.Id);
}
}
public DbSet<Clients> Clients { set; get; }
XeroWorkflowMaxContext context = new XeroWorkflowMaxContext();
context.Configuration.UseDatabaseNullSemantics = true;
var query = from line in context.Clients select line;