Linq to SQL using multiple DataContexts in a single query

I have this Linq to SQL query sequence that basically returns a search in the PROJECTS table. and I used deferred execution to slowly create it.

var query = from p in objDBContext.PROJECTs
where (p.PROVIDER_ID == cwForm.productForm) 
select p; 

query = from p in query
where p.SubmittedDate >= cwForm.beginDateForm
select p;

I have written several SQL functions that return the values ​​of scalar values ​​and tables as a helper function, since LINQ does not support ISDATE()full-text search. they are in the same .dbml file as in the table Projects.

So now I have:

var dateQuery = from d in objDBContext.ISDATE   
select d;
//returns a bool

var ftsQuery = from f in objDBContext.FullTextSearch
select f;
//returns a valued-table with the primary keys of hits with fulltextsearch

My question is: how can I use these new objDBContexts in the original p request? I'm also interested in learning how to map the executequery () element in the original query.

Sort of:

query = from p in query
        from d in dateQuery
        from f in ftsQuery
where d.ISDATE(p.Field1) &&  f.FullContextSearch(searchString)    

    select p; 

, . Google, .

+3
1

, :

var query = from p in objDBContext.Projects where
    p.PROVIDER_ID == cwForm.productForm 
    && objDBContext.ISDATE(p.Field1)
    && objDBContext.FullTextSearch(searchString)
        //assuming FullTextSearch returns boolean
    select p

FullTextSearch , , . , IList, objDBContext.FullTextSearch(searchString).Contains(p)

, , , . SQL. LINQ to SQL SQL 100% .

+2

Source: https://habr.com/ru/post/1704218/


All Articles