亜音速ライセンスが関係しているため、ソリューションを圧縮して配布できるかどうかはわかりません。適切な亜音速ではなく、約 2 か月前のものです (期限切れ)。プロジェクトを実行して、まだ機能していることをテストしました。これを行う手順は次のとおりです。
上記の UpdatableDatabase クラスを使用します。それからDBを派生させます(これをテンプレートに入れます):
パブリック部分クラス DB : UpdateableDatabase
UpdatableDatabase.cs は、生成されたクラスに含まれている必要があります。そうしないと、テーブル クラスで GetType() が必要になるため、機能しません。
このサービスは、次のクラスを持つ単なるサービス プロジェクトです。
using System.Data.Services;
using Northwind;
namespace NorthwindService
{
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults=true)]
public class Northwind: DataService<DB>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(IDataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.UseVerboseErrors = true;
}
}
}
web.config のサービス部分は簡単です。
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
次に、テスト プロジェクトに対して、サービスへのサービス参照を追加します。astoria プロジェクトからテスト コードを取得しました。
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WcfClientTest.NorthwindService;
namespace WcfClientTest
{
/// <summary>
/// Summary description for WcfTest
/// To run these tests, load this project, and somehow get a server running at the URI.
/// This can be done by updating the service reference to start the development server.
/// </summary>
[TestClass]
public class WcfTest
{
private string baseURI = "http://127.0.0.1:49649/Northwind.svc";
private DB ctx;
/// <summary>
/// Sets up test.
/// </summary>
[TestInitialize]
public void SetUp()
{
ctx = new DB(new Uri(baseURI));
}
[TestCleanup]
public void Cleanup()
{
}
[TestMethod]
public void Select_Simple_With_Variable()
{
int categoryID = 5;
IQueryable<Product> result = from p in ctx.Products
where p.CategoryID == categoryID
select p;
List<Product> products = result.ToList();
Assert.AreEqual(7, products.Count());
}
[TestMethod]
public void TestAddNew()
{
// add customer
var c = new Customer
{
CustomerID = "XXXXX",
ContactTitle = "Prez",
Country = "USA",
ContactName = "Big Guy",
CompanyName = "Big Guy Company"
};
ctx.AddToCustomers(c);
ctx.SaveChanges();
IQueryable<Customer> qCustomer = from cust in ctx.Customers
where cust.CustomerID == "XXXXX"
select cust;
Customer c2 = qCustomer.FirstOrDefault();
Assert.AreEqual("XXXXX", c2.CustomerID);
if (c2 != null)
{
ctx.DeleteObject(c2);
}
ctx.SaveChanges();
IQueryable<Customer> qCustomer2 = from cust in ctx.Customers
where cust.ContactName == "Big Guy"
select cust;
// Returns null if the row isn't found.
Customer c3 = qCustomer2.SingleOrDefault();
Assert.AreEqual(null, c3);
}
}
}
私が持っているのはこれだけです。組み立てるのは難しくありません。今は問題を探しての解決策ですが、いつか使うつもりです。subsonic を完全にバイパスして、IQToolkit を直接使用することは可能であり、いくつかの T4 テンプレートとともに、非常に優れたシステムを備えています。