日期:2014-05-20  浏览次数:20762 次

InsertOnSubmit没法用,啥原因?.
我做了两个类库。
第一个类库,专门放.dbml之类的文件。
第二个类库,引用第一个类库的dll,然后做操作。

在第二个类库里发生个奇怪的问题。
C# code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Gico.ProjectDep.Linq;

namespace Gico.ProjectDep.DAL
{
    public class DALDeparmentTree
    {
        private LinqDeparmentTreeDataContext dc = new LinqDeparmentTreeDataContext();
        public IEnumerable<DeparmentTree> FindAll()
        {
            var list = from o in dc.DeparmentTrees
                       select o;

            return list;
        }

        public void Add(DeparmentTree model)
        { 
            dc.DeparmentTrees.InsertOnSubmit(   //这个不能用,写全了也不行。        
            dc.DeparmentTrees. //这个“.”之后,啥也不出现。
        }
    }
}



但是在第一个类库里,这么写是可以的。
为什么在linq之外的其他类库里,不能这么用呢?难道少引用什么东西了。?

------解决方案--------------------
在解决方案管理器的引用里面,添加引用,加上应该就可以了