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;








0















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










share|improve this question






















  • 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


















0















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










share|improve this question






















  • 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














0












0








0


1






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










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 22 at 1:43









carlos1231carlos1231

1




1












  • 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


















  • 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

















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













1 Answer
1






active

oldest

votes


















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);





share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    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);





    share|improve this answer



























      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);





      share|improve this answer

























        0












        0








        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);





        share|improve this answer













        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);






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 1:46









        Ashkan Mobayen KhiabaniAshkan Mobayen Khiabani

        23.4k1868125




        23.4k1868125





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해