我创建了一个SOAP服务,它应该通过SubSonic查询返回Category对象和CategoryCollection。问题是我可以很好地返回DataTable数据,但是从服务返回的对象在内部是活动记录类型,而不是我的DAL实体。
例如,当我使用服务时,我看到SOAPService.Category,但不是SOAPService.CategoryCollection(我应该能够看到SOAPService。[所有其他数据实体],而SOAPService.Category是活动记录类型,并且不包含实际的类别属性。
这两个类都是通过我的SubSonic DAL生成定义的。
namespace TrainingWebService.DAL
{
/// <summary>
// Strongly-typed collection for the Category class.
/// </summary>
[Serializable]
public partial class CategoryCollection : ActiveList<Category, CategoryCollection>
{
.
.
.
和
/// <summary>
/// This is an ActiveRecord class which wraps the Categories table.
/// </summary>
[Serializable]
public partial class Category : ActiveRecord<Category>, IActiveRecord
{
.
.
.
这些类存在于TrainingWebService解决方案中。
TrainingWebService.ISOAPService.cs:
使用VRPCTrainingWebService.DAL;
命名空间TrainingWebService { // VRPC培训Web服务 - 界面 [服务合约] 公共接口ISOAPService {
[OperationContract] string GetDBConnectionStringDetails(); [OperationContract] string ReturnSameString(string someString); // // Database-related // [OperationContract] // categories CategoryCollection GetAllCategories(); // SubSonic object [OperationContract] DataTable GetAllCategoriesAsDataTable(); [OperationContract] DataTable GetCategoryAsDataTable(int id); [OperationContract] Category GetCategoryByID(int id); // SubSonic object [OperationContract] // products ProductCollection GetAllProducts(); [OperationContract] Product GetProductByID(int id); [OperationContract] // suppliers SupplierCollection GetAllSuppliers(); [OperationContract] Supplier GetSupplierByID(int id); }
}
在我的SOAPService.cs
中 public CategoryCollection GetAllCategories() // get a collection of all categories
{
return DataCaller.GetAllCategories();
}
public DataTable GetAllCategoriesAsDataTable()
{
return DataCaller.GetCategoriesAsDataTable();
}
public DataTable GetCategoryAsDataTable(int id)
{
return DataCaller.GetCategoryAsDataTable(id);
}
Here's a snip of the DataCaller code.
/// <summary>
/// Get all categories - returns a collection of categories
/// </summary>
/// <returns></returns>
public static CategoryCollection GetAllCategories()
{
categoryCollection =
DB.Select().From("Categories")
.ExecuteAsCollection<CategoryCollection>();
return categoryCollection;
}
public static DataTable GetCategoryAsDataTable(int id)
{
try
{
dtResults = new Select()
.Where(Category.Columns.CategoryID).IsEqualTo(id)
.From(Category.Schema)
.ExecuteAsCollection<CategoryCollection>().ToDataTable();
}
catch (Exception ex)
{
throw ex;
}
return dtResults;
}
我认为问题可能在于通过我的网络服务公开* .DAL实体,因此可以访问它们。
我的这个工作在我建立的另一个解决方案中工作得很好,但由于某种原因我无法看到我在这里缺少的东西。