Get Table information using foreign keyAdd a column with a default value to an existing table in SQL ServerHow to check if a column exists in a SQL Server table?How can foreign key constraints be temporarily disabled using T-SQL?What's the best practice for primary keys in tables?Table Naming Dilemma: Singular vs. Plural NamesHow can I list all foreign keys referencing a given table in SQL Server?Insert results of a stored procedure into a temporary tableHow to use LINQ to select object with minimum or maximum property valueEntity Framework Code First - two Foreign Keys from same tableGet size of all tables in database

Is it a acceptable way to write a loss function in this form?

How precise must a satellite's orbit be?

Use 1 9 6 2 in this order to make 75

How to create a cubic equation that include sums of the roots of another cubic equation

How durable are silver inlays on a blade?

Should I refuse to be named as co-author of a low quality paper?

Is it possible to have 2 different but equal size real number sets that have the same mean and standard deviation?

Can you make an identity from this product?

How can one's career as a reviewer be ended?

How do free-speech protections in the United States apply in public to corporate misrepresentations?

How to write a convincing religious myth?

Why Does Mama Coco Look Old After Going to the Other World?

Why do radiation hardened IC packages often have long leads?

Why did Intel abandon unified CPU cache?

noalign caused by multirow and colors

Rail-to-rail op-amp only reaches 90% of VCC, works sometimes, not everytime

C++ logging library

Accessing /systemTopic/ streaming channel

A Salute to Poetry

If there's something that implicates the president why is there then a national security issue? (John Dowd)

How to befriend someone who doesn't like to talk?

Is Dumbledore a human lie detector?

Who is "He that flies" in Lord of the Rings?

Can a human be transformed into a Mind Flayer?



Get Table information using foreign key


Add a column with a default value to an existing table in SQL ServerHow to check if a column exists in a SQL Server table?How can foreign key constraints be temporarily disabled using T-SQL?What's the best practice for primary keys in tables?Table Naming Dilemma: Singular vs. Plural NamesHow can I list all foreign keys referencing a given table in SQL Server?Insert results of a stored procedure into a temporary tableHow to use LINQ to select object with minimum or maximum property valueEntity Framework Code First - two Foreign Keys from same tableGet size of all tables in database






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I want to get all rows in a table where the foreign key is a set value.



So I have the line underneath to get all the values in the table Resultater



var resultater = _context.Resultater.ToArray();


I want to limit the results to only those that match the foreign key. I would imagine it to be something like:



var foreignKey = 1;
var resultater = _context.Resultater.Where(ForeignKey == foreignKey).ToArray();


The model/table looks like this




public int Id get; set;

[Required]
public string ForeignKey get; set;

[Required]
[Display(Name = "Dato")]
public DateTime Date get; set;

public string Form get; set;










share|improve this question






















  • So what is the question and what issue you are facing?

    – ssilas777
    Mar 24 at 21:43











  • In the table Resultater I have the column ForeignKey and I want all rows that match the foreignKey. The problem is that I don't know how to limit the result from _context.Resultater.ToArray();

    – Sondre
    Mar 24 at 21:52

















-1















I want to get all rows in a table where the foreign key is a set value.



So I have the line underneath to get all the values in the table Resultater



var resultater = _context.Resultater.ToArray();


I want to limit the results to only those that match the foreign key. I would imagine it to be something like:



var foreignKey = 1;
var resultater = _context.Resultater.Where(ForeignKey == foreignKey).ToArray();


The model/table looks like this




public int Id get; set;

[Required]
public string ForeignKey get; set;

[Required]
[Display(Name = "Dato")]
public DateTime Date get; set;

public string Form get; set;










share|improve this question






















  • So what is the question and what issue you are facing?

    – ssilas777
    Mar 24 at 21:43











  • In the table Resultater I have the column ForeignKey and I want all rows that match the foreignKey. The problem is that I don't know how to limit the result from _context.Resultater.ToArray();

    – Sondre
    Mar 24 at 21:52













-1












-1








-1








I want to get all rows in a table where the foreign key is a set value.



So I have the line underneath to get all the values in the table Resultater



var resultater = _context.Resultater.ToArray();


I want to limit the results to only those that match the foreign key. I would imagine it to be something like:



var foreignKey = 1;
var resultater = _context.Resultater.Where(ForeignKey == foreignKey).ToArray();


The model/table looks like this




public int Id get; set;

[Required]
public string ForeignKey get; set;

[Required]
[Display(Name = "Dato")]
public DateTime Date get; set;

public string Form get; set;










share|improve this question














I want to get all rows in a table where the foreign key is a set value.



So I have the line underneath to get all the values in the table Resultater



var resultater = _context.Resultater.ToArray();


I want to limit the results to only those that match the foreign key. I would imagine it to be something like:



var foreignKey = 1;
var resultater = _context.Resultater.Where(ForeignKey == foreignKey).ToArray();


The model/table looks like this




public int Id get; set;

[Required]
public string ForeignKey get; set;

[Required]
[Display(Name = "Dato")]
public DateTime Date get; set;

public string Form get; set;







c# asp.net sql-server model-view-controller






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 21:39









SondreSondre

356




356












  • So what is the question and what issue you are facing?

    – ssilas777
    Mar 24 at 21:43











  • In the table Resultater I have the column ForeignKey and I want all rows that match the foreignKey. The problem is that I don't know how to limit the result from _context.Resultater.ToArray();

    – Sondre
    Mar 24 at 21:52

















  • So what is the question and what issue you are facing?

    – ssilas777
    Mar 24 at 21:43











  • In the table Resultater I have the column ForeignKey and I want all rows that match the foreignKey. The problem is that I don't know how to limit the result from _context.Resultater.ToArray();

    – Sondre
    Mar 24 at 21:52
















So what is the question and what issue you are facing?

– ssilas777
Mar 24 at 21:43





So what is the question and what issue you are facing?

– ssilas777
Mar 24 at 21:43













In the table Resultater I have the column ForeignKey and I want all rows that match the foreignKey. The problem is that I don't know how to limit the result from _context.Resultater.ToArray();

– Sondre
Mar 24 at 21:52





In the table Resultater I have the column ForeignKey and I want all rows that match the foreignKey. The problem is that I don't know how to limit the result from _context.Resultater.ToArray();

– Sondre
Mar 24 at 21:52












1 Answer
1






active

oldest

votes


















2














you should change the lambda query like this



var foreignKey = 1;
var resultater = _context.Resultater.Where(x=> x.ForeignKey == foreignKey).ToArray();





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%2f55328831%2fget-table-information-using-foreign-key%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









    2














    you should change the lambda query like this



    var foreignKey = 1;
    var resultater = _context.Resultater.Where(x=> x.ForeignKey == foreignKey).ToArray();





    share|improve this answer





























      2














      you should change the lambda query like this



      var foreignKey = 1;
      var resultater = _context.Resultater.Where(x=> x.ForeignKey == foreignKey).ToArray();





      share|improve this answer



























        2












        2








        2







        you should change the lambda query like this



        var foreignKey = 1;
        var resultater = _context.Resultater.Where(x=> x.ForeignKey == foreignKey).ToArray();





        share|improve this answer















        you should change the lambda query like this



        var foreignKey = 1;
        var resultater = _context.Resultater.Where(x=> x.ForeignKey == foreignKey).ToArray();






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 24 at 21:55









        Hadi

        26.6k73175




        26.6k73175










        answered Mar 24 at 21:48









        Razmik GhookasRazmik Ghookas

        854




        854





























            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%2f55328831%2fget-table-information-using-foreign-key%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문서를 완성해