Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Coolstorage查询错误_.net_Orm_Coolstorage_Vici - Fatal编程技术网

.net Coolstorage查询错误

.net Coolstorage查询错误,.net,orm,coolstorage,vici,.net,Orm,Coolstorage,Vici,我一直在寻找Linq to SQL的开源替代方案,发现它非常适合我的需要—轻量级、开源、支持Access和SQL Server 然而,我在获取数据时遇到了一些问题,尽管它可以很好地添加数据,而且我已经使用两个不同的数据库在两个不同的环境中复制了相同的问题,所以很明显这是我做错的事情,希望有人能指出这是什么 我创建了一个新的Access mdb,它有两个表—AccountStatus和Account。AccountStatus包含AccountStatusID、AccountStatusName,

我一直在寻找Linq to SQL的开源替代方案,发现它非常适合我的需要—轻量级、开源、支持Access和SQL Server

然而,我在获取数据时遇到了一些问题,尽管它可以很好地添加数据,而且我已经使用两个不同的数据库在两个不同的环境中复制了相同的问题,所以很明显这是我做错的事情,希望有人能指出这是什么

我创建了一个新的Access mdb,它有两个表—AccountStatus和Account。AccountStatus包含AccountStatusID、AccountStatusName,而Account包含AccountID、AccountName、AccountStatusID

我已使用NuGet向我的项目添加了Vici.CoolStorage和Vici.Core引用,创建了一个域文件夹,并添加了以下两个类以映射到我的表:

帐户状态:

using Vici.CoolStorage;

namespace ViciAccount.Domain
{
    [MapTo("AccountStatus")]
    public abstract partial class AccountStatus : CSObject<AccountStatus, int>
    {
        public abstract int AccountStatusID { get; set; }
        [ToString]
        public abstract string AccountStatusName { get; set; }

        [OneToMany(LocalKey = "AccountStatusID", ForeignKey = "AccountStatusID")]
        public abstract CSList<Account> Accounts { get; }
    }
}
账户:

using Vici.CoolStorage;

namespace ViciAccount.Domain
{
    [MapTo("Account")]
    public abstract partial class Account : CSObject<Account, int>
    {
        public abstract int AccountID { get; set; }
        [ToString]
        public abstract string AccountName { get; set; }
        public abstract int AccountStatusID { get; set; }

        [ManyToOne(LocalKey = "AccountStatusID", ForeignKey = "AccountStatusID")]
        public abstract AccountStatus AccountStatus { get; set; }
    }
}
然后,我将以下代码添加到要测试的表单的加载事件中:

if (!CSConfig.HasDB())
{
    CSConfig.SetDB(new CSDataProviderAccess(@"G:\FilePath\Test Project\ViciTest.mdb"));
    CSConfig.UseTransactionScope = false;
}

CSConfig.Logging = true;
CSConfig.LogFileName = @"G:\FilePath\Test Project\vici.log";

AccountStatus accountStatus = AccountStatus.New();
accountStatus.AccountStatusName = "Live";
accountStatus.Save();

accountStatus = AccountStatus.New();
accountStatus.AccountStatusName = "Closed";
accountStatus.Save();

CSList<AccountStatus> accountStatuses = AccountStatus.List();

MessageBox.Show(accountStatuses.Count.ToString());
它成功地添加了活动记录和关闭记录,但当我尝试查询CSList的计数时失败,执行查询时出错。可能的语法错误,对象引用的InnerException未设置为对象的实例

有人知道我这里出了什么问题吗


编辑:我已将Vici.CoolStorage DLL替换为Activa.CoolStorage DLL,该DLL可追溯到2008年,现在一切正常,因此它肯定与最新版本Vici is 1.5、Activa is 1.2有关。旧版本中似乎不支持SQL日志记录,只是为了确保我正确理解您的问题:异常在accountStatuses.Count.ToString的最后一行引发?是的,完全正确。如果我试图对数据库或任何其他类型的查询运行任何特殊SQL,它也会抛出相同的错误。但是在所有这些情况下,使用Activa Library同样的代码可以很好地工作。我想在这里帮助您,所以您可以通过电子邮件将代码和MDB文件发送给我吗?我想这只是一个没有任何敏感数据的测试项目。查看我的个人资料以获取我的电子邮件地址。感谢您提供的帮助,但是在我查看您的个人资料时,您的电子邮件地址不会显示?