Debian 7 Linq To SQL String对象引用上的Mono未设置为对象的实例 [英] Mono on Debian 7 Linq To SQL String object reference not set to an instance of an object

查看:57
本文介绍了Debian 7 Linq To SQL String对象引用上的Mono未设置为对象的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Linux和Mono的新手.我正在使用Mono 3.6和Debian 7.6

hi I'm new to Linux and mono. I am using Mono 3.6 and Debian 7.6

我一直在获取未设置为对象实例的对象引用.我使用的是在VS 2013的Windows上编译的相同代码,而且效果很好.

I keep getting object reference not set to an instance of an object. I use the same code that I compile on windows with VS 2013 and it works fine.

  string connstring = string.Format
("Data Source={0},{1};Initial Catalog={2};User ID={3};Password={4};Application Name={5};Connect Timeout=120",
   IP, Port, database, Username, Password, InstanceID);

 settings = new ConnectionStringSettings("sqlServer", 
                                       connstring, "System.Data.SqlClient");


 using (data = new SwitchDataDataContext(settings.ConnectionString)){
                   BlockList.Clear();
                    foreach (var item in data.BlockLists)
                    {// so this works
                        if (BlockList.ContainsKey(item.TN) == false)
                            BlockList.TryAdd(item.TN, item.TN);
                        }
// this is where it crashes
  var custs = data.CustomerGateways.Where(p => p.isEnabled == true);

}

当我调用代码时,它将引发异常.

When I call the code it throws an exception.

有什么主意吗?

在Windows上运行正常.

works fine on Windows.

我将异常写入屏幕. DbLinq.Data.Linq.Mapping.AttributedMetaType + c__Iterator0.MoveNext()[0x00000]在System.Collections.Generic.List System.Data.Linq.Mapping.MetaAssociation .AddEnumerable

I wrote the exception to the screen. DbLinq.Data.Linq.Mapping.AttributedMetaType+c__Iterator0.MoveNext() [0x00000] in :0 at System.Collections.Generic.List System.Data.Linq.Mapping.MetaAssociation .AddEnumerable

推荐答案

好,我知道了.在Linq的地图中,您具有所有联接的表.这些联接需要是内部的而不是公共的.过去,我必须序列化数据时才这样做.出于某种原因而公开,例如PK循环.

Ok I figured it out. In the Linq's Map for all the tables you have joins. Those joins need to be Internal not Public. I've done this in the past when I have to serialize the data. Public for some reason causes like a looping of PK's.

无论哪种方式,都可以在Linq Map中将其更改为内部,并且可以使用.

Either way change the thing to internal in the Linq Map and it works.

这篇关于Debian 7 Linq To SQL String对象引用上的Mono未设置为对象的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆