我有英镑服务
public sealed class SterlingService : IApplicationService, IApplicationLifetimeAware, IDisposable
{
private SterlingEngine _engine;
private static readonly ISterlingDriver _driver = new IsolatedStorageDriver();
public static SterlingService Current { get; private set; }
public ISterlingDatabaseInstance Database { get; private set; }
public static void StartUpDatabase()
{
Current.Database = Current._engine.SterlingDatabase.RegisterDatabase<LocalDB>(_driver);
}
....
....
}
我有表定义的我的 LocalDB 类是:
public class LocalDB : BaseDatabaseInstance
{
protected override List<ITableDefinition> RegisterTables()
{
return new List<ITableDefinition>()
{
CreateTableDefinition<ContactData, Guid>(k => k.UID.Value)
.WithIndex<ContactData, int, Guid>("CustomerId", t => t.CustomerId.Value),
CreateTableDefinition<ContactDetailData, Guid>(k => k.ContactData.UID.Value)
.WithIndex<ContactDetailData, int, Guid>("CustomerId", t => t.ContactData.CustomerId.Value),
....
};
}
}
现在的问题是当我从存储中获取数据时。保存工作正常,但是当我获取时,我得到“从字符串到 Guid 的无效转换操作异常”。
public static List<ContactData> GetContactListFromLocalDB(int customerId)
{
var data = (from k in SterlingService.Current.Database.Query<ContactData, int, Guid>("CustomerId")
where k.LazyValue != null && k.Index == customerId
select k.LazyValue.Value);
return data.ToList<ContactData>(); (**HERE I GET THE EXCEPTION**)
}
请让我知道我在哪里做错了。
谢谢。