Entity SQL, checking for existance of disk file RRS feed

  • Question

  • Hi--

    I have an EntityDatasource where I use Entity SQL in the Command text to get some results.  Is there any Entity SQL function to see if a disk file exists, or can I call a C# function from Entity SQL?

    Or call a stored procedure from SQL Server where I use  "xp_cmdshell 'dir E:\myfile.txt', NO_OUTPUT"?  I would prefer a solution that can be implemented in the site code.

    Or could filtering be done in an event of the grid to which the results of my query gets bound?

    Thans in advance for any suggestions or comments.


    Wednesday, April 25, 2012 1:04 PM

All replies

  •  EF is an ORM database solution not a file system solution. You can use
    System.IO Fileexist there is no need to be shelling out any where.
    Wednesday, April 25, 2012 1:35 PM
  • Rght, I understand how to use file.exists. 

    I apologize for not being clearer.  I need to apply additional filtering to the results of an entitydatasource result set based on whether a file exists or not.

    In particular, I have an application for job recrituers to search thru a database of students.  They can specify various criteria such as educational level or state in which they are located -- standard database search stuff.  But additonally, I want the searcher to be able to limit his search to those who have uploaded a .PDF of their resume, hense my question.  The entity datasource is bound to a grid.

    I found this thread

    and this post:

    I tried this:

        protected void EDSResults_Selected(object sender, EntityDataSourceSelectedEventArgs e)
            if (cv_provided.Checked)
                DataTable dt = (DataTable)e.Results;

    But I can't cast e.results to a databable, and can't find any examples of using EntityDataSourceSelectedEventArgs.Results.

    I did manage to read a field I need to determine the file name from Results:

            System.Collections.IEnumerable recs = e.Results;
            foreach (DbDataRecord rec in recs)
                if (!File.Exists("~/CVs/" + (rec["ScholarID"] as string).Trim() + ".pdf"))
                    //  cannot find how do delete record from results.
    but I cannot find a way to remove the row from Results.

    Thanks in advance for any ideas.


    • Edited by Dennis H Sunday, April 29, 2012 10:43 PM
    Sunday, April 29, 2012 3:15 AM