关于附属物发现的问题 [英] Question on Attached property discovery

查看:42
本文介绍了关于附属物发现的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用System.Data.Objects命名空间中的ObjectContext类,该命名空间位于程序集System.Data.Entity 4.0 dll中。 它包含许多扩展方法,允许我通过LINQ做这种事情:

I'm working with the ObjectContext class found in the System.Data.Objects namespace which is in the assembly System.Data.Entity 4.0 dll.  It contains many extension methods that allow me to do this kind of thing via LINQ:

using (Models.Entities1 ae1 = new Models.Entities1())
{
    var stuff = ae1.ItemMaster.Where(p => p.itnbr.ToLower().Contains("atp"));
    foreach (var thing in stuff.OfType<Models.ItemMaster>())
    {
                  
        ae1.Attach(thing);
        ae1.DeleteObject(thing);
        ae1.SaveChanges();
    }
}

此代码直接在嵌入控件的WPFland中没有问题。

This code works directly with no problem in WPFland embedded into a control.

所以我希望将此访问权转移到服务中。 我能够启动并运行服务,连接到数据库等。 但是这个完全相同的代码找不到
的扩展方法 Attach,DeleteObject ....什么给出了? 我已经获得了所有适当的引用和使用声明。 这两个项目都针对相同的框架.... 

So I wanted to move this access to a Service instead.  I was able to get the service up and running, connect to the DB etc.  But this same exact code cannot find the extension methods for Attach, DeleteObject.... What gives?  I valildated I have all the proper references and using statements.  Both projects are targetting same Framework.... 

错误  674 'ServiceLibrary.Model.Entities'不包含'Attach'的定义没有扩展方法'Attach'接受类型'ServiceLibrary.Model.Entities'的第一个参数可以找到(你是否缺少using指令或
程序集引用?) 

我想也许服务可能不允许部分汇编类? 似乎不可能。

I am thinking perhaps that maybe services doesn't allow part of the assembly classes?  Doesn't seem possible.

JP Cowboy Coders Unite!

JP Cowboy Coders Unite!

推荐答案

好的我可能偶然发现了根本原因:

Ok I may have stumbled on root cause:

 在WPFL中,当使用EF时,它生成了实体基类,该类继承自ObjectContext,使用EF生成从DBContext中获取的模型时的Service项目。

  In WPFLand when using EF it generated the entity base class which inherits from ObjectContext, the Service project when using EF to generate the model inhertied from DBContext.

这必须是根本原因但不是确定如何纠正...任何线索?

This must be the root cause but am not sure how to correct that... Any clues?


这篇关于关于附属物发现的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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