none
Why does my code bail out in the middle? RRS feed

  • Question

  • I am learning the entity framework and linq.  I succeeded in creating an app, connecting to the test database and filling a grid and stuff.  So now I tried going to production and nothing happens.  No crash, no error, nothing.  I tried referencing my test exe and I get the same results.  I have no idea what needs to be done since there is no error.  But it dies on the linq.  If anyone can give me any idea on where to look / what to try / something!  Getting nothing can be hard but when you are using a new technology it can be especially debilitating.  I'm going to go ahead and write my own data manager in the hopes I can trash it, but I'm on plan B now.

    Using VS2015 on Windows 7 64-bit to SQL Server 2016 >Net 4.6.1.

            private void frmInvoiceCheck_Load(object sender, EventArgs e)
            {
                List<SalesRegion> boel;
                List<string> cusl;
                VermillionDataEntities DM = new VermillionDataEntities();
                SalesEntities TEST = new SalesEntities();
    
                MessageBox.Show("Before");//Prints this
                var queryT = from SalesRegion boe in TEST.SalesRegions
                             select boe;
                MessageBox.Show("After"); //Never prints this
                boel = queryT.ToList();
                dgvInvoiceData.DataSource = boel;
    
                var query = from BillingOrderEntry boe in DM.BillingOrderEntries 
                            select boe.FirstName + " " + boe.LastName;
    
                cusl = query.ToList();
                cboPatient.DataSource = cusl;
    
            }

    Both ling requests die.  The app keeps running because I have a button on it and when I click it I always get XXX.

            private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("XXX");
            }
    Is there a way I can use the entity framework without linq?  All the examples I see use linq.  If it works without linq I'm fine with that.  linq doesn't do me much good if I can't get my entity framework to work

    • Moved by DotNet Wang Thursday, September 1, 2016 1:55 AM
    Wednesday, August 31, 2016 7:10 PM

Answers

All replies

  • Hi MarDude,

    Thank you posting here.

    Since your issue is related to ADO.NET Entity framework forum. So I will move the thread to there.

    Best Regards,

    Hart


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Thursday, September 1, 2016 1:53 AM
  • Hi MarDude,

    According to your description and related code, please remove SalesRegion from your LINQ statement, like this:

    var queryT = from boe in TEST.SalesRegions
                             select boe;

    And

    var query = from boe in DM.BillingOrderEntries 
                            select boe.FirstName + " " + boe.LastName;
    

    For more information about LINQ, please refer to:

    https://msdn.microsoft.com/en-us/library/mt693024.aspx

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, September 1, 2016 5:21 AM
    Moderator
  • Well, how did you learn to use EF? Did you get a book and learn or did you just start winging it figuring that you didn't need any good learning material?
    Friday, September 2, 2016 2:50 AM
  • Thanks for your reply Cole

    My code was confusing because I was testing lots of things.  I found out it was a missing connection string.  I dont have any error handling and dont know why it did not throw an error.  I even rebooted my machine and it still did not throw an error until I made several changes.  Oh well.

    Friday, September 2, 2016 3:04 PM
  • Ah books.  I like books, I have over 200 of them.  Unfortunately the last tech book I bought was VB6 and COM.  Spent $50 for it and it was worth it.  Now it is completely useless but can easily last 50 more years.  I do still buy fiction books though.   They can still have use in 20 years where as a tech book is not only less current then the information on the internet, but it contributes to the deforestation of the planet.

    So lets see, buy a book that will not be as current as the information I can easily retrieve from the net, kill trees and consume natural resources all for something that will greatly outlast its usefulness.  Sorry, as much as I like books I have to come to the realization that tech books is like a horse and buggy to a car or the sliderule to a calculater. You can see this as more and more documentation is provided online.  While yes books do work, it is not a good option for someone who changes with the times and adapts themselves to the changing world.  They do work really well for someone who has difficulty adapting to new technology though, so there is a place for them.  Just not for me.

    Friday, September 2, 2016 3:14 PM
  • > So now I tried going to production and nothing happens.  No crash, no error, nothing.

    MessageBox.Show() is not a good way to figure out problems in your code.

    Let Visual Studio help you: Debugger Basics

    David


    David http://blogs.msdn.com/b/dbrowne/

    Friday, September 2, 2016 4:06 PM
  • Ah books.  I like books, I have over 200 of them.  Unfortunately the last tech book I bought was VB6 and COM.  Spent $50 for it and it was worth it.  Now it is completely useless but can easily last 50 more years.  I do still buy fiction books though.   They can still have use in 20 years where as a tech book is not only less current then the information on the internet, but it contributes to the deforestation of the planet.

    So lets see, buy a book that will not be as current as the information I can easily retrieve from the net, kill trees and consume natural resources all for something that will greatly outlast its usefulness.  Sorry, as much as I like books I have to come to the realization that tech books is like a horse and buggy to a car or the sliderule to a calculater. You can see this as more and more documentation is provided online.  While yes books do work, it is not a good option for someone who changes with the times and adapts themselves to the changing world.  They do work really well for someone who has difficulty adapting to new technology though, so there is a place for them.  Just not for me.

    I disagree with all of this about books. Yeah my company provides PluralSight. It's alright but it get tiresome on the eyes. I learned EF back 2008 with a book on EF showing me the way with examples I could run and see what was happening. I use books and there wrong in doing it.

    The point is did you do any formal training on EF, or are you just winging it looking at some online examples? 

    Friday, September 2, 2016 5:46 PM
  • You disagree DA that a computer book will outlive its usefullness?  Want to buy some then?  I have some that I have no use for but if you think they are usefull you can have them cheap!!

    But I digress, by the way I rearranged the code and finally got it to stop at the catch block.  It seems sometimes EF can bomb out with out throwing an error.  Pity.

    Anyway this question can be closed.

    Tuesday, September 6, 2016 1:32 PM