/// <summary> /// /// </summary> /// <exception cref="NotSupportedException"></exception> /// <param name="id"></param> /// <returns></returns> public virtual T GetById(int id) { if (!typeof(T).GetInterfaces().Any(f => f == typeof(IIntIdRecord))) { throw new NotSupportedException("GetById(int id) is supported only if the Reposytory's type implements IIntIdRecord interface"); } string containerName = _objectContext.DefaultContainerName; string setName = _objectContext.CreateObjectSet <T>().EntitySet.Name; // Build entity key var entityKey = new EntityKey(containerName + "." + setName, "Id", id); return((T)_objectContext.GetObjectByKey(entityKey)); }