草庐IT

entity_type_id

全部标签

c# - LINQ to Entities Group By 表达式给出 'Anonymous type projection initializer should be simple name or member access expression'

我在这个表达式中遇到了上述错误:varaggregate=fromtinentities.TraceLinesjoinminentities.MethodNames.Where("it.NameLIKE@searchTerm",newObjectParameter("searchTerm",searchTerm))ont.MethodHashequalsm.MethodHashwhere(t.CallTypeId&(int)types)==t.CallTypeId&&t.UserSessionProcessId==m_SessionIdgrouptbym.Nameintodselect

c# - LINQ to Entities 无法识别方法 'Int32 Int32(System.String)' 方法,并且无法将此方法翻译成存储表达式

我正在尝试使用LinqtoEntities查询数据库上下文,但出现此错误:LINQtoEntitiesdoesnotrecognizethemethod'Int32Int32(System.String)'method,andthismethodcannotbetranslatedintoastoreexpression.`代码:publicIEnumerableGetCourseName(){varcourse=fromoinentities.UniversityCoursesselectnewCourseNames{CourseID=Convert.ToInt32(o.Course

c# - Entity Framework 过滤器 "Expression<Func<T, bool>>"

我正在尝试为EntityFramework列表创建一个过滤方法并更好地理解Expression我有一个这样的测试函数。publicIQueryableFilter(IEnumerablesrc,Expression>pred){returnsrc.AsQueryable().Where(pred);}如果我这样做:context.Table.Filter(e=>e.ID或者这个:context.Table.Filter(e=>e.SubTable.Where(et=>et.ID0&&e.ID一切正常。但是如果我这样做:context.Table.Filter(e=>e.SubTable

c# - ReferentialConstraint 中的依赖属性映射到存储生成的列。列 : 'ID'

当我尝试添加Venue对象并调用SaveChanges()时,我不明白为什么会出现此错误。模型中与Venue对象的唯一区别是它们与City是1对1..0关系。Citycity=ProcessCityCache(ev,country,db);//Afterthiscall,'city'isalreadypersisted.venue=newVenue{TicketMasterURL=ev.VenueSeoLink,Name=Capitalize(ev.VenueName),City=city};db.Venues.AddObject(venue);db.SaveChanges();//E

c# - 无法将类型 'System.Data.EntityState' 隐式转换为 'System.Data.Entity.EntityState' 。存在显式转换(您是否缺少转换?)

我在使用EntityFramework时在asp.net中遇到此错误:“无法将类型System.Data.EntityState隐式转换为System.Data.Entity.EntityState。存在显式转换(是否缺少强制转换?)”这是片段:foreach(OrderLinelineinorder.OrderLines){context.Entry(line.Product).State=System.Data.EntityState.Modified;}请建议我应该如何解决错误。 最佳答案 当您使用EF6或从EF5迁移到EF6

c# - 检查 System.Type 是否是给定类的后代的最佳方法

考虑以下代码:publicclassA{}publicclassB:A{}publicclassC:B{}classD{publicstaticboolIsDescendantOf(thisSystem.TypethisType,System.TypethatType){///???}voidMain(){AcValue=newC();C.GetType().IsDescendantOf(cValue.GetType());}}实现IsDescendantOf的最佳方法是什么? 最佳答案 Type.IsSubclassOf()判断当

c# - Entity Framework 代码首先更新数据库在 CREATE DATABASE 上失败

ThisposthasbeennotedSohasthisone在我的开发机器上,我正在尝试使用包管理器控制台中的更新数据库重新创建我的数据库。我相信我已按照上述帖子中的说明进行操作。我收到此错误消息:Afileactivationerroroccurred.Thephysicalfilename'\WRDatabase.mdf'maybeincorrect.Diagnoseandcorrectadditionalerrors,andretrytheoperation.CREATEDATABASEfailed.Somefilenameslistedcouldnotbecreated.C

c# - 属性 'name'是对象关键信息的一部分,不能修改。 Entity Framework

我正在尝试更新记录,但在context.SaveChanges();之后收到此错误消息Theproperty'name'ispartoftheobject'skeyinformationandcannotbemodified.这是更新函数的代码:if(context.EAT_SourceNames.Any(e=>e.name==newSourceName)){MessageBox.Show("NamealreadyexistsintheDatabase");}else{varnameToUpdate=context.EAT_SourceNames.SingleOrDefault(e=>

c# - Entity Framework 5 MaxLength

我正在使用EF4和我发现的一段代码来从这样的实体获取MaxLength值:publicstaticint?GetMaxLength(stringentityTypeName,stringcolumnName){int?result=null;using(fooEntitiescontext=newfooEntities()){TypeentType=Type.GetType(entityTypeName);varq=frommetaincontext.MetadataWorkspace.GetItems(DataSpace.CSpace).Where(m=>m.BuiltInTypeK

c# - Entity Framework - 打印 EntityValidationErrors 以记录

打印日志时出现以下错误Message:Validationfailedforoneormoreentities.See'EntityValidationErrors'propertyformoredetails.;StackTrace:atSystem.Data.Entity.Internal.InternalContext.SaveChanges()EntityValidationErrors对象包含不同节点中的完整详细错误。打印它的最佳方法是什么? 最佳答案 更简洁的语法:catch(System.Data.Entity.Val