Tag: 实体

linq to sql startwith performance索引列

我首先使用实体​​代码。 索引列: SourceCatalogId 残 CategoryPath 表中有40 000行, 我的问题是查询需要40s !! var result = DBContext.Set() .Include(x => x.SalesHistories, x => x.SourceCatalog) .Where(p => p.SourceCatalogId == 2) .where(p => p.Disabled == false) .where(x => x.CategoryPath.StartsWith(“MyPath”)) .orderby(x => x.ShortDesignation) .Skip(1) .Take(10) .toList(); SQL通过sql profiler: exec sp_executesql N’SELECT TOP (10) [Project1].[SourceProductId] AS [SourceProductId], [Project1].[SourceSKU] AS [SourceSKU], [Project1].[SourceCatalogId] AS [SourceCatalogId], [Project1].[ManufacturerReference] […]

在entity framework中使用存储过程,如何让实体填充其导航属性?

entity framework非常慢,所以我尝试使用存储过程,但我遇到了这个问题。 entity framework允许您定义生成实体的存储过程。 但是,我的实体具有“导航属性”,使用此方法时未填充这些属性。 有工作吗?

不支持直接绑定到商店查询(DbSet,DbQuery,DbSqlQuery)的数据

我在visual studio 2012上编码并使用实体模型作为我的数据层。 但是,使用Linq语句的下拉控件往往会在页面尝试加载时抛出未处理的exception(上面标题)。 这是我的代码如下; using (AdventureWorksEntities dw = new AdventureWorksEntities()) { ddlCon.DataSource = (from em in dw.Employees select new { em.Title, em.EmployeeID }); ddlCon.DataTextField = “Title”; ddlCon.DataValueField = “EmployeeID”; ddlCon.DataBind(); ddlCon.Items.Insert(0, new ListItem(“–Select–“, “–Select–“)); } 我想知道为什么会发生错误 使用LINQ时绑定到控件的正确方法是什么?