简体   繁体   中英

IntelliSense doesn't show partial class method

I have partial class User generated by LINQtoSQL as shortly following:

    [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:

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:

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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