Robb Hill
asked on
.net Return Value error
I have the following code...I am looking to refactor for best practices..and testing for errors..etc.
Also how would I return this value ...
And if refactored to handle this linq differently then I guess ignore the return part of the question.
The error is me passing to array..
Perhaps this should just be fixed..or there is a better way to accomplish.
I would like to utilize the best design practice.
Also how would I return this value ...
And if refactored to handle this linq differently then I guess ignore the return part of the question.
The error is me passing to array..
Perhaps this should just be fixed..or there is a better way to accomplish.
I would like to utilize the best design practice.
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void btnProcess_Click(object sender, EventArgs e)
{
// format files types from UI to be used in linq
String[] FileTypes = txtFileTypes.Text.Split(new Char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
//Take source directory and validate against the static path. Return the match
String source = txtSource.Text;
source = Path.GetPathRoot(txtSource.Text);
//get document listing using filetypes and source of static path as primary filters
var documents = GetDocumentsbyPathandId(FileTypes, source);
}
//take source value from UI and determine the static path root share
public DocInfo[] GetDocumentsbyPathandId(string[] FileTypes,string source)
{
SqlDbContext sqlDb = new SqlDbContext("SqlDbContext", null);
source = Path.GetPathRoot(txtSource.Text);
var docInfo = from d in sqlDb.Documents
join s in sqlDb.Sites on d.SiteCode equals s.SiteCode
where FileTypes.Contains(d.TypeId)
where s.ParentSiteCode == ""
where d.LinkedDocumentId == 0
where d.Udf3.Trim() == ""
where d.Path.StartsWith(source)
select new
{
DocumentId = d.DocumentId,
DocumentCode = d.DocumentCode,
TypeId = d.TypeId,
ParentCategory = d.ParentCategory,
ChildCategory = d.ChildCategory,
Title = d.Title,
FileName = d.FileName,
Path = d.Path,
SiteCode = d.SiteCode,
Udf1 = d.DocumentCategory
};
return docInfo.ToArray();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you!!!
Not a problem Robb, glad to help.
ASKER