我在使用实体框架4的查询时遇到了问题:
List<SomeResult> test = (from a in _entities.TableA
select new SomeResult
{
TestB = a.TableB.Name,
TestCDict = a.TableC.ToDictionary(x => x.SomeKey, x => x.SomeVa
在我的类中,我有一个IDictionary,实体(类)作为键,角色(枚举)作为值。在试图保存新实例(非持久化)的情况下,在IDictionary中填充实体的新实例时,我会得到以下错误:
NHibernate.TransientObjectException:对象引用未保存的瞬态实例--在刷新之前保存瞬态实例。类型:实体
这些是类(角色是枚举):
public class Case
{
public Case { EntityCollection = new Dictionary<Entity, Roles>(); }
public virtual int Id
我正在寻找一种在实际添加之前在entityCollection的函数Add中添加逻辑的方法,例如,当你有一个拥有entityCollection的实体时,你可以这样做:
car.passengers.Add(passenger)
例如,我想检查是否有不超过5名乘客,所以我尝试这样的分机:
static public void Add(this EntityCollection<passenger> Passenger, Passenger Passenger)
{
// some logique (in fact i want throw an exception here
我第一次使用实体框架,并注意到实体对象返回实体集合。
DBEntities db = new DBEntities();
db.Users; //Users is an ObjectSet<User>
User user = db.Users.Where(x => x.Username == "test").First(); //Is this getting executed in the SQL or in memory?
user.Posts; //Posts is an EntityCollection<Post>
Post post =
我想把一个列表转换成EntityCollection。
List<T> x = methodcall();
EntityCOllection<T> y = new EntityCollection<T>();
foreach(T t in x)
y.Add(t);
我知道这个错误。
无法将对象添加到EntityCollection或EntityReference中。附加到ObjectContext的对象不能添加到不与源对象关联的EntityCollection或EntityReference中。
有人知道这个错误吗?
我有一些实体
EntityCollection retrievedEntities =(EntityCollection)serviceProxy.RetrieveMultiple(query);
从retrievedEntities中,我想从具有attribule值=的特定实体中检索属性值到某个值(string或int )
一个linq查询能完成这个任务吗??
var q = from p in retrieve.Entities
where p.Attributes.Keys = "new_attribute1" &&
我有一个.NET windows窗体属性网格,它与实体集合相关联。
public class Entity
{
public string A { get; set; }
public string B { get; set; }
public string C { get; set; }
}
它有一个从collectioneditor派生并附加到实体集合的集合编辑器。当从属性网格调用集合编辑器时,它工作得非常好。
[Editor(typeof(EntityCollectionEditor), typeof(UITypeEditor))]
public EntityCollectio
我目前正在尝试保存一个EntityCollection,它在不同的场景中填充了新的和脏的实体对象。
我已经设置了一个事务,以便在保存失败时回滚。
但是,它似乎总是失败,并在两种情况下抛出一个Error...in,保存一个新的或现有的EntityCollection。
我还有一个方法,它选择并将单个实体(即LanguagetranslationEntity )添加到类中定义为属性的Entitycollection中。
public EntityCollection<LanguageTranslationEntity> LanguagetranslationCollection { g
我在我的项目中使用EntityFramework POCO +代理+延迟加载。今天,我非常惊讶地看到Transaction类将其相关集合Rows实现为HashSet (而不是EntityCollection)。我需要EntityCollection来跟踪集合中的更改。
public class Transaction
{
public virtual ICollection<TransactionRow> Rows { get; set; }
}
但是,其他实体类将其相关集合物化到EntityCollection中。
我通过ObjectQuery加载Transaction,
我有一个实体类,它可以被各种不同的类继承。在这个实体类中,我有一个名为Identity的属性,它的类型基于TIdentity泛型。我正在创建另一个具有Entity泛型类型的类,例如EntityCollection。我不知道如何为实体类设置where子句。我需要那个特定类的where子句,因为我需要访问EntityCollection类中的Identity属性。
下面是实体类。
public abstract class Entity<TIdentity> where TIdentity : Identity, new()
{
protected Entity()
{
我使用的是MVC2和实体框架。
我有2个实体集合,我需要比较它们,并检查它们是否有任何共同的项目。例如,假设我有EntityCollection<Candidate>和EntityCollection<Job>。我正在尝试返回所有拥有该职位首选技能中列出的技能的候选人。这是正确的吗:
public IQueryable<Candidate> GetMatchingCandidates(Job job)
{
return from candidate in _db.Candidates
where (cand
为虚拟实体创建插件,同时尝试将EntityCollection解析为PluginExecutionContext (在Microsoft.Xrm.Sdk中),但它在消息中失败
错误
"message":"OutputParameters must contain a property called 'BusinessEntityCollection' of type Microsoft.Xrm.Sdk.EntityCollection for SDK message RetrieveMultiple",
代码就像
stri
我使用反射从我的EntityCollection<Derived>域实体获取EF4属性。示例实体可能有许多集合,这些集合包含具有公共基的类型。GetValue()返回一个object,但我需要将它转换为EntityCollection<Base>,甚至是IEnumerable<Base>。但是怎么做呢?(哎呀,对IEnumerable的转换就像C#4那样起作用)
示例模型
public class Derived : Base { ... }
public class AnotherDerived : Base { ... }
public class Ex
假设我有以下实体:
public class Post
{
public int Id { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
}
当我从数据库检索Post对象时,我需要将Comments集合转换为EntityCollection<T>,以便可以检查与该集合相关的一些EF4数据,比如数据是否被紧急加载。
不幸的是,如果我试图进行从ICollection<T>到EntityCollection<T>的直接转换,我会得到一个异常,
当在实体上填充过滤后的子EntityFramework时,EntityCollection看起来非常慢-
我们使用用C#编写的数据库优先实体框架和Silverlight客户端运行一个RIA/WCF。我们收集了大约70,000个'Eval‘实体和类似数量的'InCo’实体。每个Eval都有一个包含最多2个InCo实体的子集合。这种关系是一对多的,所以Eval可以有多个InCos,但是InCo绑定到单个Eval。在从数据库中加载实体集合之后,我将循环遍历各个层次,如下所示-
foreach(Eval eval in Evals)
if (eval.InCos
我有一个使用Entity framework创建的实体对象,并在Silverlight中与RIA服务框架一起使用。
所讨论的实体有两个EntityCollections,它们包含在发送给客户端的IQueriable中。
该实体如下所示:
public class Ad:Entity
{
[Include]
public EntityCollection<PublishingDates> PublishingDates {get;set;}
[Include]
public EntityCollection<Notice> Not