473,414 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

While using a SubQuery, Outer variable for query becomes unaccessible to inner query.

Expand|Select|Wrap|Line Numbers
  1. public static dynamic GetTaxonomies(int businessUnitId, int memberId, string businessUnitType)
  2.         {
  3.             using (var db = new ProtocolManagementDatabaseEntities())
  4.             {
  5.                 var taxonomies = (from taxonomy in db.taxonomies
  6.                                   join businessUnitTaxonomy in db.businessunittaxonomies on taxonomy.taxonomyid equals businessUnitTaxonomy.taxonomyid
  7.                                   let TaxonomyID = taxonomy.taxonomyid
  8.                                   where businessUnitTaxonomy.businessunitid == businessUnitId
  9.                                   select new
  10.                                   {
  11.                                       TaxonomyId = taxonomy.taxonomyid,
  12.                                       TaxonomyName = taxonomy.taxonomyname,
  13.                                       preferenceValue = db.userpreferences.Where(x => x.entitycolumnvalue == TaxonomyID &&
  14.                                       x.memberid == memberId && x.entitytablename == "Taxonomy" && x.sequencenumber == 5)
  15.                                       .Select(x => x.isvisible).FirstOrDefault()
  16.  
  17.                                       AppCategory = (from appCategory in db.appcategories
  18.                                                      join appCategoryTaxonomy in db.appcategorytaxonomies on appCategory.appcategoryid equals appCategoryTaxonomy.appcategoryid
  19.                                                      let AppCategoryID = appCategory.appcategoryid
  20.                                                      where appCategory.parentappcategoryid == null &&
  21.                                                      appCategory.appcategorylevel.Equals("AppCategoryName")
  22.                                                      && appCategoryTaxonomy.taxonomyid == TaxonomyID &&
  23.                                                      appCategoryTaxonomy.businessunitid == businessUnitId
  24.  
  25.                                                      orderby appCategory.name ascending
  26.                                                      select new
  27.                                                      {
  28.                                                          AppCategoryId = appCategory.appcategoryid,
  29.                                                          AppCategoryName = appCategory.name,
  30.  
  31.                                                          AppCategoryDeletionEnable = db.appcategories.Where(x => x.parentappcategoryid == AppCategoryID)
  32.                                                          .FirstOrDefault() != null ? true : false
  33.  
  34.                                                          SubCategory = from subCategory in db.appcategories
  35.                                                                        let SubCategoryID = db.appcategories.Where(x => x.appcategoryid == subCategory.appcategoryid).Select(x => x.appcategoryid).FirstOrDefault()
  36.                                                                        where subCategory.parentappcategoryid == AppCategoryID && subCategory.businessunitid == businessUnitId
  37.                                                                        orderby subCategory.name ascending
  38.                                                                        select new
  39.                                                                        {
  40.                                                                            AppCategoryId = subCategory.appcategoryid,
  41.                                                                            AppCategoryName = subCategory.name,
  42.                                                                            Description = subCategory.description,
  43.                                                                            IsGlobal = subCategory.isglobal,
  44.                                                                            IsEnable = subCategory.isenable,
  45.                                                                            ParentAppCategoryID = appCategory.parentappcategoryid,
  46.                                                                                    SubCategoryDeleteEnable = db.protocolappcategories.Where(x => x.appcategoryid == SubCategoryID)
  47.                                                                            .FirstOrDefault() != null ? true : false,
  48.  
  49.                                                                            AppCategoryLevel = subCategory.appcategorylevel,
  50.                                                                            IsExpand = false,
  51.                                                                        }
  52.                                                      }).ToList()
  53.                                   }).ToList();
  54.                 return taxonomies;
  55.             }
  56.         }
My project has subqueries used inside nested Query.While using a subquery inside the inner query, variable declared in outer query becomes unaccesible to inner queries inside it.
Error found while debugging nested queries:
1. Unknown column 'Join3.appcategoryid' in 'field list'
2. Unknown column 'Extent1.taxonomyid' in 'where clause'
Nov 23 '18 #1
0 971

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: sivaram | last post by:
Hi all, I have the following query in Visual Foxpro that is throwing error. UPDATE T1 set T1.C2 = (select T2.C2 from T2 where T1.c1 = T2.C1)
2
by: gkellymail | last post by:
the following query works fine: select link.idx, link.x_table, link.x_id_a, link.x_id_z, a.strandid, b.strandid from link_detail, link, strand A, strand B where link_detail.x_table =...
1
by: Dax | last post by:
Hi, I have a problema of query in an asp page, if I run the query in sql query analizer is time running it's about 3-4 seconds, if I made the same query in an asp page it create the error of...
1
by: santoshsri | last post by:
Hi below is a SQL Query written at SQL Server 2000. The result has been ordered by a.Location_Number , a.Transaction_Date, but in output the result is not ordered for eg : I am getting records for...
3
by: nico3334 | last post by:
I currently have a query that Joins 2 Tables (Table1 and Table2) using LEFT OUTER JOIN. Here is an example of that query: SELECT a.supply, a.state, b.cost FROM Table1 a LEFT...
1
maxamis4
by: maxamis4 | last post by:
I have the following query that I am trying to carry over from ms access to ms sql server. I keep getting a msg 156, level 15, state 1, line 2 Incorrect syntax near the keyword "INNER". it works...
0
by: acoppini | last post by:
I am trying to use string variables LIN and Portfolio defined from a recordset recControl in VBA SQL Select Query in Microsoft Access 2003. My syntax must be wrong as I keep getting a Syntax error....
1
by: rush2hem | last post by:
I am trying to build a query which will give me unique rows. Details:- Table 1 (F1, F2 are the columns) F1 F2 1 A1 2 A2 3 A3 4 A4 Table 2 (F3,F4 are the columns) F3 F4
1
by: abcrf | last post by:
Trying to run an update query with multiple join statements in VBA, but I keep getting "missing operator" errors. Same happens when I try to run the SQL in query builder. The SQL is: UPDATE...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.