I have this Linq Join
var NewQuote = (from qw in Q
join NW in NewNotes on qw.RECID equals NW.RECID into temp
from j in temp
select new Quotes
{
QuoteNumber = qw.QuoteNumber,
CustPartNumber = qw.CustPartNumber,
ITEMGROUPID = qw.ITEMGROUPID,
LotSize = qw.LotSize,
EAU = qw.EAU,
CONTACTPERSONID = qw.CONTACTPERSONID,
QUOTATIONSTATUS = qw.QUOTATIONSTATUS,
QUOTESENTDATE = qw.QUOTESENTDATE,
PricePerPiece = qw.PricePerPiece,
QuoteValue = qw.QuoteValue,
Email = qw.Email,
RECID = qw.RECID,
Notes = j == null ? "" : j.NOTES
}).ToList();
Q is of the Quote class but I need to add the data to the Notes field from NewNotes. Is there a better way to do this than listing every field from the Quote class? If I have to add fields to Quote then I have to document to come to this section of code and update as well.
Why you create new instances of Quotes
if you just want to update one property?
var query = from qw in Q join NW in NewNotes
on qw.RECID equals NW.RECID into temp
from j in temp
select new { Quote = qw, Notes = j?.Notes ?? "" };
foreach(var x in query)
{
x.Quote.Notes = x.Notes;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.