Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VS 2013 can not evaluate expression
Message
From
07/08/2014 11:34:17
 
General information
Forum:
ASP.NET
Category:
Troubleshooting
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01605242
Message ID:
01605303
Views:
35
This message has been marked as a message which has helped to the initial question of the thread.
>>>Do you know how to adjust these two calls:
>>
>>Adjust in what way ?
>>
>>>
>>> public PagedResult<Operator> GetOperators(QueryRequest queryRequest)
>>>        {
>>>            return _operatorRepository.GetPagedRequest(queryRequest);
>>>        }
>>>
>>>
>>>Do you know how to create a shorter object on the fly? The Operator object has lots of columns and I just want to return a few (in particular, OpCode, FirstName, LastName and Hidden)
>>>
>>>>>        public IEnumerable<Operator> GetAllOperators()
>>>        {
>>>            return _operatorRepository.GetAll();
>>>        }
>>I think you will need a concrete 'short form' of the Operator class (unless you want to mess with dynamics)
>>One solution: Create an implicit or explicit cast from 'Operator' to 'ShortOperator' then you should be able to tack '.Select((x => (ShortOperator) (x)))' onto the end of the GetAll(). If you don't want to implement the casting then use 'Select(x => new ShortOperator() {Name = x.Name})' etc.
>>
>>One advantage of using a cast is that it can be used on single Operator instances as well..
>
>I was thinking along the same lines. So, do I always need to change the signature of that method to be
>
>public PagedResult<OperatorList>
>
>instead of current implementation?
>
>Will I also have to change the repository interface as well?
>
>Our application is quite complex and I am a bit confused as where should I made the change exactly.

Without knowing more detail on the layers it's hard to say. But I'd be inclined to leave the base class alone. If you do that you could simply add an additional method to the child class. So given an implicit cast to 'ShortOperator' you could just add a method:
public IEnumerable<ShortOperator> GetAllShortOperators()
 {
     return  _operatorRepository.GetAll().Select((x => (ShortOperator)(x)));
  }
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform