Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VS 2013 can not evaluate expression
Message
 
 
À
07/08/2014 06:19:45
Information générale
Forum:
ASP.NET
Catégorie:
Problèmes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01605242
Message ID:
01605304
Vues:
45
>>RepositoryBase has this code
>>
>>
>> public virtual T GetById(object id)
>>        {
>>            return _dbSet.Find(id);
>>        }
>>
>
>Raises more questions than it answers :-{
>The class containing the virtual is obviously generic so how is it defined. I'd guess 'T:Class' and that the return from GetById() is an instance of Operator.
>I'd also guess that the sub class is defined as inheriting
: parent<Operator>
?
>Are those assumptions correct?
>
>IAC, from what you say is doesn't sound as if an exception is being thrown - why not just step the call to see what is happening?

This is the beginning of the base Repository class
 public abstract class RepositoryBase<T> : IRepository<T> where T : class
    {
        protected readonly ISysManagerContext _context;
        protected readonly IDbSet<T> _dbSet;
        private readonly IExceptionParser _exceptionParser;

        public RepositoryBase(ISysManagerContext context)
        {
            _context = context;
            _dbSet = _context.Set<T>();
            _exceptionParser = new ExceptionParser();
        }

        public virtual IEnumerable<T> GetAll()
        {
            return _dbSet;
        }        

        public virtual IEnumerable<T> GetAll(params string[] includes)
        {
            var query = _dbSet.AsQueryable();
            includes.ToList().ForEach(x => query = query.Include(x));

            return query;
        }

        public virtual PagedResult<T> GetPagedRequest(QueryRequest queryRequest)
        {
            var query = QueryHelper.GetFilteredQuery<T>(_dbSet.AsQueryable(), queryRequest);
            var pagedResultMessage = QueryHelper.GetPagedResult(query, queryRequest);
            return pagedResultMessage;
        }

        public virtual T GetById(object id)
        {
            return _dbSet.Find(id);
        }

        public virtual void Add(T entity)
        {
            EntityState entityState = _context.GetEntityState(entity);
            if (entityState != EntityState.Detached)
            {
                _context.SetAdd(entity);
            }
            else
            {
                _dbSet.Add(entity);
            }
            try
            {
                SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                _exceptionParser.ThrowUniqueConstraintException(ex);
            }

        }
I've been tracing it yesterday. My original question was why I can not see the variable (and its properties) in the debugger. I can trace it down step by step again today. I also plan today to look more closer to which exact line of code causing the SQL Server to execute the query.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform