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
Guest User
Tech Writer
611
128.1k
Remove duplicacy in linq c# .
Aug 10 2020 12:16 PM
I have an issue. How to remove duplicate record from list. It's me code please check.
public
class
SupplementResponse
{
public
int
Response {
get
;
set
; }
public
string
ErrorMessage {
get
;
set
; }
public
List<SupplementListDetail> lst_Supplement {
get
;
set
; }
public
List<SupplementDetail> lstOf_Supplement {
get
;
set
; }
}
public
class
SupplementDetail
{
public
int
SupplementsId {
get
;
set
; }
public
string
SupplementType {
get
;
set
; }
public
string
SupplementPDF {
get
;
set
; }
public
int
SupplementStatus {
get
;
set
; }
}
public
class
SupplementListDetail
{
public
int
SupplementsId {
get
;
set
; }
public
string
SupplementType {
get
;
set
; }
public
string
SupplementPDF {
get
;
set
; }
public
int
SupplementStatus {
get
;
set
; }
}
SupplementResponse obj_result =
new
SupplementResponse();
List<SupplementListDetail> lst =
new
List<SupplementListDetail>();
List<SupplementDetail> list =
new
List<SupplementDetail>();
var result = lst.Union(list).ToList();
//Face Issue here
var PDFURL =
new
ConfigurationBuilder().AddJsonFile(
"appsettings.json"
).Build().GetSection(
"AppSettings"
)[
"SupplementUrl"
];
try
{
var matchingdata = (from c
in
_context.TblSupplementDetail
join sc
in
_context.SupplementMaster on c.SupplementId equals sc.SupplementId
where c.UserId == obj_parameter.UserId
select
new
{
sc.SupplementId,
sc.SupplementType,
sc.SupplementPdf,
c.SupplementStatus
}).ToList();
if
(matchingdata.Count > 0)
{
foreach
(var item
in
matchingdata)
{
SupplementListDetail obj_supplement =
new
SupplementListDetail();
obj_supplement.SupplementsId = item.SupplementId;
obj_supplement.SupplementType = item.SupplementType;
obj_supplement.SupplementPDF = PDFURL +
""
+ item.SupplementPdf;
obj_supplement.SupplementStatus = Convert.ToInt32(item.SupplementStatus);
lst.Add(obj_supplement);
}
}
var Supplement_List = _context.SupplementMaster.ToList();
{
if
(Supplement_List .Count >0)
{
foreach
(var item
in
Supplement_List)
{
SupplementDetail obj_supplement =
new
SupplementDetail();
obj_supplement.SupplementsId = item.SupplementId;
obj_supplement.SupplementType = item.SupplementType;
obj_supplement.SupplementPDF = PDFURL +
""
+ item.SupplementPdf;
obj_supplement.SupplementStatus = Convert.ToInt32(item.SupplementStatus);
list.Add(obj_supplement);
}
}
}
obj_result.Response = 1;
obj_result.ErrorMessage =
"No Error Found"
;
obj_result.lst_Supplement = lst;
obj_result.lstOf_Supplement = list;
}
catch
(Exception ex)
{
obj_result.Response = 0;
obj_result.ErrorMessage =
"Internal Server Error"
;
}
return
obj_result;
it's my code. It's more important for me
Reply
Answers (
1
)
Basic authentication against membership user table for static file.
C# Serial Communication -- Adafruit Metro M4 and Grand Central M4