简体   繁体   English

IntelliSense不显示部分类方法

[英]IntelliSense doesn't show partial class method

I have partial class User generated by LINQtoSQL as shortly following: 我有下面由LINQtoSQL生成的部分类User:

    [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.[User]")]
public partial class User : INotifyPropertyChanging, INotifyPropertyChanged
{

    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
 ...

Then I created separate folder "Proxy" in my project and put there extra piece of User class: 然后,我在项目中创建了单独的文件夹“ Proxy”,并在其中放置了User类的其他内容:

namespace LINQtoSQL_sample.Proxy
{
    public partial class User
    {
        public static string GetActivationUrl()
        {
            return Guid.NewGuid().ToString("N");
         ...

Issue happens when I try to invoke that extra static method from another part of same project. 当我尝试从同一项目的另一部分调用该额外的静态方法时,就会发生问题。 Let's say I have once more folder "SqlRepositoryImpl" and another one partial class there: 假设我再有一个文件夹“ SqlRepositoryImpl”和另一个局部类:

namespace LINQtoSQL_sample.SqlRepositoryImpl
{
    public partial class SqlRepository
    {
        public bool CreateUser(User instance)
        {
            if (instance.ID == 0)
            {
                instance.added_date = DateTime.Now;
                instance.activated_link = LINQtoSQL_sample.Proxy.User.GetActivationUrl();
              ...

As you can see I explicitly defined which part of User class I'm calling for because IntelliSense didn't suggest me my extra method. 如您所见,由于IntelliSense并未建议我使用我的额外方法,因此我明确定义了要调用的User类的哪一部分。

Please, advise why such happens and where I'm wrong? 请告诉我为什么会发生这种情况以及我错在哪里?

As you can see I explicitly defined which part of User class I'm calling for because IntelliSense didn't suggest me my extra method. 如您所见,由于IntelliSense并未建议我使用我的额外方法,因此我明确定义了要调用的User类的哪一部分。

When you call a method from a class, there are no “parts” of the class anymore. 当您从类中调用方法时,该类不再有“部分”。

If you need to (and can) specify the full namespace of the class to invoke a method from it that means you actually have two different classes in two different namespaces. 如果需要(并且可以)指定类的完整名称空间以从中调用方法,则意味着您实际上在两个不同的名称空间中具有两个不同的类。 If the two partial declarations are in different namespaces, then you have actually declared two separate classes, not a single class from two parts. 如果两个partial声明位于不同的命名空间中,则实际上已经声明了两个单独的类,而不是两个部分中的单个类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM