无法在名称空间内使用“使用”进行编译

时间:2019-12-04 16:35:08

标签: c# visual-studio namespaces code-formatting

我有以下代码:

false

我已经在using Data; using MyProject_API.Models.ViewModels; using System.Linq; using Utilities.Web.Authentication; namespace MyProject_API.Services.EmailTemplates { /// <summary> /// Defines the <see cref="EmailTemplatesSearch" /> /// </summary> public class EmailTemplatesSearch { /// <summary> /// Initializes a new instance of the <see cref="EmailTemplatesSearch"/> class. /// </summary> /// <param name="dataContext">The dataContext<see cref="DataContext"/></param> /// <param name="user">The user<see cref="MyProjectIdentity"/></param> public EmailTemplatesSearch(DataContext dataContext, MyProjectIdentity user) { _db = dataContext; _user = user; } 的帮助下清除了代码,并获得了以下代码:

CodeFormatter

如您所见,namespace MyProject_API.Services.EmailTemplates { using MyProject_API.Models.ViewModels; using System.Linq; using Utilities.Web.Authentication; /// <summary> /// Defines the <see cref="EmailTemplatesSearch" /> /// </summary> public class EmailTemplatesSearch { /// <summary> /// Initializes a new instance of the <see cref="EmailTemplatesSearch"/> class. /// </summary> /// <param name="dataContext">The dataContext<see cref="DataContext"/></param> /// <param name="user">The user<see cref="MyProjectIdentity"/></param> public EmailTemplatesSearch(DataContext dataContext, MyProjectIdentity user) { _db = dataContext; _user = user; } 失去了CodeFormatter。我尝试将using Data;添加到使用列表中,但是无法编译代码,找不到using Data;名称空间中的DataContext。我解决了将Data从命名空间移到外部的问题,但看起来像拐杖。 using Data;的定义类似于

DataContext

enter image description here

  • 为什么namespace Data { public class DataContext 失去CodeFormatter
  • 为什么using Data;在命名空间中不起作用?

我搜索了类似的问题: LINQ to SQL Designer BugShould 'using' directives be inside or outside the namespace?等,但我仍然不明白如何解决我的问题

0 个答案:

没有答案