Best way to compare two classes (Users and Holidays) and create a list of Users who have not created an instance of the Holiday class with LINQWhat is the correct way to create a single-instance WPF application?Create an instance of a class from a stringCreate a list from two object lists with linqBest way to compare two large string lists, using C# and LINQ?Compare two list elements with LINQBest way to compare two complex objectsQuickest way to compare two List<>If my interface must return Task what is the best way to have a no-operation implementation?Foreign key on Identity UserUser is only able to like one post
Can I find out the caloric content of bread by dehydrating it?
What does 'script /dev/null' do?
Email Account under attack (really) - anything I can do?
Why is my log file so massive? 22gb. I am running log backups
Piano - What is the notation for a double stop where both notes in the double stop are different lengths?
Is "plugging out" electronic devices an American expression?
Does the average primeness of natural numbers tend to zero?
Add an angle to a sphere
Eliminate empty elements from a list with a specific pattern
Travelling to Edinburgh from India
Shall I use personal or official e-mail account when registering to external websites for work purpose?
What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?
COUNT(id) or MAX(id) - which is faster?
New order #4: World
How to manage monthly salary
Copycat chess is back
Information to fellow intern about hiring?
extract characters between two commas?
Extreme, but not acceptable situation and I can't start the work tomorrow morning
What is the command to reset a PC without deleting any files
"My colleague's body is amazing"
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Calculate Levenshtein distance between two strings in Python
Could Giant Ground Sloths have been a Good Pack Animal for the Ancient Mayans
Best way to compare two classes (Users and Holidays) and create a list of Users who have not created an instance of the Holiday class with LINQ
What is the correct way to create a single-instance WPF application?Create an instance of a class from a stringCreate a list from two object lists with linqBest way to compare two large string lists, using C# and LINQ?Compare two list elements with LINQBest way to compare two complex objectsQuickest way to compare two List<>If my interface must return Task what is the best way to have a no-operation implementation?Foreign key on Identity UserUser is only able to like one post
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I apologize if this is badly worded, I'm a relatively new English speaker.
I have 2 classes: Holidays and ApplicationUsers
The Holidays class has a foreign key of the ApplicationUserId taken from the ApplicationUsers class
I'm trying to create a new list of Users who have not created instances of the Holiday class
Below is the code I am trying to use:
NotBooked = await _db.ApplicationUser.Include(i => i.Holidays).Where(i => i.Id != i.Holidays.ApplicationUserId).ToListAsync();
I'm struggling to create a list of Users whose ApplicationUser ForeignKey is not present within the Holidays items.
Is there a better way to do this?
Many Thanks
c# asp.net .net linq
add a comment |
I apologize if this is badly worded, I'm a relatively new English speaker.
I have 2 classes: Holidays and ApplicationUsers
The Holidays class has a foreign key of the ApplicationUserId taken from the ApplicationUsers class
I'm trying to create a new list of Users who have not created instances of the Holiday class
Below is the code I am trying to use:
NotBooked = await _db.ApplicationUser.Include(i => i.Holidays).Where(i => i.Id != i.Holidays.ApplicationUserId).ToListAsync();
I'm struggling to create a list of Users whose ApplicationUser ForeignKey is not present within the Holidays items.
Is there a better way to do this?
Many Thanks
c# asp.net .net linq
If you want users without holidays then this should dodb.Applicationuser.Where(u => !u.Holidays.Any())
– juharr
Mar 22 at 1:47
You need to useWhere(i => i.Holidays.Count()>0)
– Chetan Ranpariya
Mar 22 at 1:48
@ChetanRanpariya That seems to be the opposite because they want users that do not have holidays.
– juharr
Mar 22 at 1:49
Oh... My mistake...Where(i => i.Holidays.Count() == 0)this should work.
– Chetan Ranpariya
Mar 22 at 1:55
add a comment |
I apologize if this is badly worded, I'm a relatively new English speaker.
I have 2 classes: Holidays and ApplicationUsers
The Holidays class has a foreign key of the ApplicationUserId taken from the ApplicationUsers class
I'm trying to create a new list of Users who have not created instances of the Holiday class
Below is the code I am trying to use:
NotBooked = await _db.ApplicationUser.Include(i => i.Holidays).Where(i => i.Id != i.Holidays.ApplicationUserId).ToListAsync();
I'm struggling to create a list of Users whose ApplicationUser ForeignKey is not present within the Holidays items.
Is there a better way to do this?
Many Thanks
c# asp.net .net linq
I apologize if this is badly worded, I'm a relatively new English speaker.
I have 2 classes: Holidays and ApplicationUsers
The Holidays class has a foreign key of the ApplicationUserId taken from the ApplicationUsers class
I'm trying to create a new list of Users who have not created instances of the Holiday class
Below is the code I am trying to use:
NotBooked = await _db.ApplicationUser.Include(i => i.Holidays).Where(i => i.Id != i.Holidays.ApplicationUserId).ToListAsync();
I'm struggling to create a list of Users whose ApplicationUser ForeignKey is not present within the Holidays items.
Is there a better way to do this?
Many Thanks
c# asp.net .net linq
c# asp.net .net linq
asked Mar 22 at 1:43
carlos1231carlos1231
1
1
If you want users without holidays then this should dodb.Applicationuser.Where(u => !u.Holidays.Any())
– juharr
Mar 22 at 1:47
You need to useWhere(i => i.Holidays.Count()>0)
– Chetan Ranpariya
Mar 22 at 1:48
@ChetanRanpariya That seems to be the opposite because they want users that do not have holidays.
– juharr
Mar 22 at 1:49
Oh... My mistake...Where(i => i.Holidays.Count() == 0)this should work.
– Chetan Ranpariya
Mar 22 at 1:55
add a comment |
If you want users without holidays then this should dodb.Applicationuser.Where(u => !u.Holidays.Any())
– juharr
Mar 22 at 1:47
You need to useWhere(i => i.Holidays.Count()>0)
– Chetan Ranpariya
Mar 22 at 1:48
@ChetanRanpariya That seems to be the opposite because they want users that do not have holidays.
– juharr
Mar 22 at 1:49
Oh... My mistake...Where(i => i.Holidays.Count() == 0)this should work.
– Chetan Ranpariya
Mar 22 at 1:55
If you want users without holidays then this should do
db.Applicationuser.Where(u => !u.Holidays.Any())– juharr
Mar 22 at 1:47
If you want users without holidays then this should do
db.Applicationuser.Where(u => !u.Holidays.Any())– juharr
Mar 22 at 1:47
You need to use
Where(i => i.Holidays.Count()>0)– Chetan Ranpariya
Mar 22 at 1:48
You need to use
Where(i => i.Holidays.Count()>0)– Chetan Ranpariya
Mar 22 at 1:48
@ChetanRanpariya That seems to be the opposite because they want users that do not have holidays.
– juharr
Mar 22 at 1:49
@ChetanRanpariya That seems to be the opposite because they want users that do not have holidays.
– juharr
Mar 22 at 1:49
Oh... My mistake...
Where(i => i.Holidays.Count() == 0) this should work.– Chetan Ranpariya
Mar 22 at 1:55
Oh... My mistake...
Where(i => i.Holidays.Count() == 0) this should work.– Chetan Ranpariya
Mar 22 at 1:55
add a comment |
1 Answer
1
active
oldest
votes
If a user does not have a holiday, then there will be no Holiday record for it in Holidays table, so:
_db.ApplicationUser.Where(u => !u.Holidays.Count() == 0);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291696%2fbest-way-to-compare-two-classes-users-and-holidays-and-create-a-list-of-users%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If a user does not have a holiday, then there will be no Holiday record for it in Holidays table, so:
_db.ApplicationUser.Where(u => !u.Holidays.Count() == 0);
add a comment |
If a user does not have a holiday, then there will be no Holiday record for it in Holidays table, so:
_db.ApplicationUser.Where(u => !u.Holidays.Count() == 0);
add a comment |
If a user does not have a holiday, then there will be no Holiday record for it in Holidays table, so:
_db.ApplicationUser.Where(u => !u.Holidays.Count() == 0);
If a user does not have a holiday, then there will be no Holiday record for it in Holidays table, so:
_db.ApplicationUser.Where(u => !u.Holidays.Count() == 0);
answered Mar 22 at 1:46
Ashkan Mobayen KhiabaniAshkan Mobayen Khiabani
23.4k1868125
23.4k1868125
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55291696%2fbest-way-to-compare-two-classes-users-and-holidays-and-create-a-list-of-users%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you want users without holidays then this should do
db.Applicationuser.Where(u => !u.Holidays.Any())– juharr
Mar 22 at 1:47
You need to use
Where(i => i.Holidays.Count()>0)– Chetan Ranpariya
Mar 22 at 1:48
@ChetanRanpariya That seems to be the opposite because they want users that do not have holidays.
– juharr
Mar 22 at 1:49
Oh... My mistake...
Where(i => i.Holidays.Count() == 0)this should work.– Chetan Ranpariya
Mar 22 at 1:55