Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ect并复制那里的实体。我将尝试将它们移出,并让您知道发生了什么。@Robertcode它在其他项目中起作用。但具体来说。您应该添加现有项目,并选择您的modeleemployee.ttasadd-as链接到其他项目。@Robertcode我发布了一个完整_C#_Winforms_Entity Framework_N Tier Architecture_Layered - Fatal编程技术网

C# ect并复制那里的实体。我将尝试将它们移出,并让您知道发生了什么。@Robertcode它在其他项目中起作用。但具体来说。您应该添加现有项目,并选择您的modeleemployee.ttasadd-as链接到其他项目。@Robertcode我发布了一个完整

C# ect并复制那里的实体。我将尝试将它们移出,并让您知道发生了什么。@Robertcode它在其他项目中起作用。但具体来说。您应该添加现有项目,并选择您的modeleemployee.ttasadd-as链接到其他项目。@Robertcode我发布了一个完整,c#,winforms,entity-framework,n-tier-architecture,layered,C#,Winforms,Entity Framework,N Tier Architecture,Layered,ect并复制那里的实体。我将尝试将它们移出,并让您知道发生了什么。@Robertcode它在其他项目中起作用。但具体来说。您应该添加现有项目,并选择您的modeleemployee.ttasadd-as链接到其他项目。@Robertcode我发布了一个完整的分步回答,可能对未来的读者有用。希望对您有所帮助:)如果我调用该服务只是像您那样给我一个计数,那么它确实有效。但是,当我引用实体名称时,仍然存在相同的问题。您是否能够使其与以下内容一起工作:List aListOfCategories=bus


ect并复制那里的实体。我将尝试将它们移出,并让您知道发生了什么。@Robertcode它在其他项目中起作用。但具体来说。您应该添加现有项目,并选择您的
modeleemployee.tt
as
add-as链接
到其他项目。@Robertcode我发布了一个完整的分步回答,可能对未来的读者有用。希望对您有所帮助:)如果我调用该服务只是像您那样给我一个计数,那么它确实有效。但是,当我引用实体名称时,仍然存在相同的问题。您是否能够使其与以下内容一起工作:List aListOfCategories=business.GetAll();从您的示例中,我假定Category是一个具有用于形成模型的属性的类。我的UI仍然不知道模型实体,例如本例中的类别。可能是因为实体中的名称空间仍然指向DALI测试解决方案,并且它工作正常。我测试
newproductbusiness().GetAll().ForEach(x=>{MessageBox.Show(x.Name);})它工作正常到底是什么问题?我完全确定答案。我做了一个工作示例,截图来自工作示例。如果您遵循以下步骤,则不需要在
UI
中引用任何
DAL
。这在您的UI项目中有效吗:List-aListOfCategories=business.GetAll();或者您可以在WinForm中的任何位置声明一个Category类吗?我用product对它进行了测试,答案是肯定的,它工作正常。例如,我可以运行
var products=business.GetAll()products.ForEach(x=>{MessageBox.Show(x.Name);})
namespace SampleNtierDAL
{
    public class DalServices
    {
        public static List<Employee> GetEmployees()
        {
            List<Employee> employeeList = null;
            using (SampleNtierEntities aSampleNtierEntitiesDbContext = new SampleNtierEntities())
            {
                employeeList = (from emp in aSampleNtierEntitiesDbContext.Employees select emp).ToList();
            }
            return employeeList;
        }
    }
}
namespace SampleNtierBLL
{
    public class BllSerices
    {
        public static List<Employee> GetEmployees()
        {
            return DalServices.GetEmployees();
        }
    }
}
namespace SampleNtierUI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnGetListOfEmployees_Click(object sender, EventArgs e)
        {
            List<Employee> anEmployeeList = BllSerices.GetEmployees();
        }
    }
}
const string inputFile = @"..\SampleNiter\SampleNtierDAL\ModelEmployee.edmx
if (container.FunctionImports.Any())
{
#>
using System.Data.Entity.Core.Objects;
using System.Linq;
using SampleNtierModels;
<#
}
using SampleNtierModels;
using SampleNtierDAL;
using SampleNtierModels;
using SampleNtierModels;
using SampleNtierBLL
public class YourEntityBusinessLogic
{
    public List<YourEntity> GetAll()
    {
        var context = new YourDBContext();
        return context.YourEntities.ToList();
    }
} 
//Shows count of records in your table
var business = new YourEntityBusinessLogic();
MessageBox.Show(business.GetAll().Count().ToString());