Solved

How can I set in mvc viewmodel my id if id = 0 and if id.hasvalue id = id.value

Posted on 2014-09-07
1
187 Views
Last Modified: 2016-02-17
I have   CrewPerVessel vess = new CrewPerVessel();
                        vess = _crewperVesselRepository.GetFirstItem(x => x.CrewPerVesselId == crewpergroup.CrewId && x.EmployeeProfilePersonalDetail.Position.PositionName == "Boat Captain");

and i have  obj.id = (vess.id == null)? vess.id = 0 : obj.id = vess.id

after running the execution if i got object not reference to object and i know this code above obj.id = (vess.id == null)? vess.id = 0 : obj.id = vess.id makes my project stop. Can you help me guys if how can make this work?
0
Comment
Question by:jabz ayuap
1 Comment
 

Accepted Solution

by:
jabz ayuap earned 0 total points
ID: 40309209
I got my answer already obj.EmployeeId = (vess == null) ? obj.EmployeeId = 0 : obj.EmployeeId = vess.EmployeeProfileId; this solve my problem
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help convert tsql to linq to entity 3 37
C# Linq - Not In 5 47
Math homework question 5 100
Permutation and Combination 9 116
Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question