However, if you try to replace that object with itself (carshowwinSFSX.dff + carshowglassSFSX.txd), you do NOT get the same result. Neither of this method directly works with inheritance - you must provide base type to make it work. Object ID 3851 (A glass window) has perfectly fine alpha channel rendering and no issues occur. Here is more general approach which can work with any key type and name and here is approach working with complex keys. The method is not so efficient because it builds these names over and over. The difference is that first method always query the database even if you have already loaded the instance to the context whereas second approach first checks if the instance is already loaded. Return (TEntity)Context.GetObjectByKey(entityKey) Var entityKey = new EntityKey(containerName + "." + setName, "Id", id) String setName = context.CreateObjectSet().EntitySet.Name String containerName = context.DefaultContainerName You just have to use another method to get your entity: public virtual T GetByKey(int id) where T : class, IEntity You can also use similar approach to one provided in the linked question. Return context.CreateObjectSet().SingleOrDefault(e => e.Id = id) You can define interface implemented by all your entities: public interface IEntityĪnd method to retrieve your entity: public T GetObjectById(int id) where T : class, IEntity
0 Comments
Leave a Reply. |