Click here to Skip to main content
16,004,927 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Only Save Contentpage Pin
Not Active4-Jul-11 2:19
mentorNot Active4-Jul-11 2:19 
GeneralRe: Only Save Contentpage Pin
Shameel4-Jul-11 7:44
professionalShameel4-Jul-11 7:44 
QuestionLinq to SQL dbml file Pin
indian1431-Jul-11 13:19
indian1431-Jul-11 13:19 
AnswerRe: Linq to SQL dbml file Pin
Philippe Mori1-Jul-11 13:56
Philippe Mori1-Jul-11 13:56 
GeneralRe: Linq to SQL dbml file Pin
indian1431-Jul-11 14:54
indian1431-Jul-11 14:54 
GeneralRe: Linq to SQL dbml file Pin
Philippe Mori1-Jul-11 16:01
Philippe Mori1-Jul-11 16:01 
GeneralRe: Linq to SQL dbml file Pin
indian1431-Jul-11 19:12
indian1431-Jul-11 19:12 
GeneralRe: Linq to SQL dbml file Pin
Philippe Mori2-Jul-11 2:58
Philippe Mori2-Jul-11 2:58 
I don't know if Linq to SQL make this information available but you can always test it "directly" if you need to. Check online help or code to see if a method exists to check for the existance.

I think that in my case I was doing an SQL query to check the existance of columns in a table when doing database upgrade. For that, you should do a google search.

As I said, handling the exception would be in my opinion the way to handle that... as even if you check the existance of the table, there is a slim chance that the table is deleted by the job between the check and the actual use of the table.

Also checking the existance explicitly will required twice as must request to update your view except if you instead write SQL stored procedure but then you won't be able to use Linq to SQL as you do.

IEnumerable<MyData> GetData()
{
  IEnumerable<MyData> enumerable = null;
  try
  {
    var query = 
      from m in dataContext
      select m;

    enumerable = query.AsEnumerable();
  }
  catch (SQLException ex)
  {
    if (ex.SomeCheck)
    {
       // Empty enumerator
       var list = new List<MyData>();
       enumerable = list;
    }
    else
    {
       // Unknown problem --- rethrow the exception
       throw;
    }
  }

  return enumerable;
}


You might also check : http://stackoverflow.com/questions/4520209/how-to-check-if-table-exists-in-model-but-not-in-database[^]

Or

http://leedumond.com/blog/check-if-a-table-exists-in-a-sql-server-database/[^]

Or

http://stackoverflow.com/questions/167576/sql-server-check-if-table-exists[^]

But I have warn you that if the jobs and the view run asynchronously, there is a slim chance that you could have an exception even if you do the check. That percentage will depend mainly on how often jobs are run and the duration of operation. If jobs run every few seconds and check are done at a similar rate, there is an high probabily to have an exception even with a check. On the other hand, if update are done every few hours it might take year before the problem would occurs once.

The best way is to first add the exception check and test the code. If it works and you still want to add a check anyway and don't bother with the extra SQL request, you can then add that the check being confident that the catch would get the exception in case of a bad timing.
Philippe Mori

AnswerRe: Linq to SQL dbml file Pin
Not Active1-Jul-11 15:12
mentorNot Active1-Jul-11 15:12 
QuestionLinq to SQL is taking more memory Pin
indian14330-Jun-11 14:06
indian14330-Jun-11 14:06 
AnswerRe: Linq to SQL is taking more memory [modified] Pin
Not Active30-Jun-11 15:07
mentorNot Active30-Jun-11 15:07 
GeneralRe: Linq to SQL is taking more memory Pin
indian14330-Jun-11 17:58
indian14330-Jun-11 17:58 
GeneralRe: Linq to SQL is taking more memory Pin
Not Active30-Jun-11 18:18
mentorNot Active30-Jun-11 18:18 
AnswerRe: Linq to SQL is taking more memory Pin
dasblinkenlight1-Jul-11 3:44
dasblinkenlight1-Jul-11 3:44 
GeneralRe: Linq to SQL is taking more memory Pin
indian1431-Jul-11 8:43
indian1431-Jul-11 8:43 
GeneralRe: Linq to SQL is taking more memory Pin
dasblinkenlight1-Jul-11 9:02
dasblinkenlight1-Jul-11 9:02 
AnswerRe: Linq to SQL is taking more memory Pin
Philippe Mori1-Jul-11 14:04
Philippe Mori1-Jul-11 14:04 
AnswerRe: Linq to SQL is taking more memory Pin
Shameel3-Jul-11 20:35
professionalShameel3-Jul-11 20:35 
QuestionLinqToExcel in win 64 bit Pin
Dhyanga30-Jun-11 8:10
Dhyanga30-Jun-11 8:10 
AnswerRe: LinqToExcel in win 64 bit Pin
Not Active30-Jun-11 8:13
mentorNot Active30-Jun-11 8:13 
GeneralRe: LinqToExcel in win 64 bit Pin
Dhyanga30-Jun-11 8:26
Dhyanga30-Jun-11 8:26 
GeneralRe: LinqToExcel in win 64 bit Pin
Parwej Ahamad30-Jun-11 9:11
professionalParwej Ahamad30-Jun-11 9:11 
GeneralRe: LinqToExcel in win 64 bit Pin
Not Active30-Jun-11 9:39
mentorNot Active30-Jun-11 9:39 
AnswerRe: LinqToExcel in win 64 bit Pin
Parwej Ahamad30-Jun-11 9:22
professionalParwej Ahamad30-Jun-11 9:22 
Questionis it impossible read asp file in visual studio2010? Pin
buffering8330-Jun-11 2:46
buffering8330-Jun-11 2:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.