TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Denmark Puso
NA
232
50.7k
How set value if there is no data in another table?
Sep 9 2019 1:11 AM
ill try to locate if my data is existing to other table and get the value of it. the problem is if there is no match in the other table i got an error but there's a match the controller save the value in my database. this is my code
and i got this error: Object reference not set to an instance of an object. if the "ReceiverCityId" has no value in "Location " i got an error. plsss help i need to set value into 0 if the "ReceiverCityId" has no value in "Location "
var rate = _rateService.GetRatebyParentId(Convert.ToInt32(pickup.Client.ParentClientId ?? 0));
var transaction =
new
Transaction
{
Source =
"Pickup"
,
TransactionId = pickup.Id,
Amount = (rate !=
null
? rate.RateItems.FirstOrDefault(x => x.Location ==
_cityService.Get(pickup.ReceiverCityId).Name).Amount : 0) - 10,
DateCreated = DateTime.Now,
CreatedBy = User.Identity.Name,
ReferenceNumber = pickup.ReferenceNumber
};
_transactionService.Add(transaction);
Reply
Answers (
1
)
How to create get dynamic string interpolation string in C#
Vue Js with Typescript and mvc application