.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

Join linq queries with same field name

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
 
Hi everyone-I'm trying to join three Linq queries together.  One of the fields (rating) is the same name for each so when I add b.rating as you'll see below, I get a squiggly that says "Anonymous type member or property 'rating' is alread declared.   Dim customerCategoryA= (From a In dc.CategoryARatings _                                  Where a.userID = userID _                                  Select New With {a.productID, a.rating, a.ratingComment}) Dim customerCategoryB = (From b In dc.CategoryBRatings _                                 Where b.userID = userID _                                 Select New With {b.productID, b.rating}) Dim DataForGridview = From p In Products _   


View Complete Post


More Related Resource Links

Which tier do Linq queries belong?

  

Started in middle of a new project.  Our design architecture uses an n-tier (not MVC - no controllers) structure with Presentation, Data, Business and Service tiers.  However the lead analyst has the majoriety of code all in the Business tier claiming it all contains Business logic.  Our data tier is nothing more than a single .dbml model of the primary database to support all of the Linq queries in the Business tier.  To my mind Linq queries and classes they use are data access and belong in the data tier  but our lead analyst says they contain business logic therefore have to be in business layer.  


Data Points: LINQ Projection Queries and Alternatives in WCF Services

  

LINQ's ability to project randomly shaped data into anonymous types can be a blessing and a source of frustration, says Julie Lerman. It's great when you just need to grab a special view of your data, but it can be problematic in certain circumstances. She explains what the limitations are and how to get around them.

Julie Lerman

MSDN Magazine May 2010


Data Points: Precompiling LINQ Queries

  

Did you know that by precompiling LINQ queries you might actually be degrading your app's performance if you're not careful? Julie Lerman explains how to ensure you're not re-precompiling queries each time and losing the expected performance benefits across post-backs, short-lived service operations and other code where critical instances are going out of scope.

Julie Lerman

MSDN Magazine March 2010


Toolbox: Easy LINQ Queries, Becoming A Better Developer, And Logging Help

  

This month Toolbox provides help with error logging, finds an app that helps you write LINQ queries, and explores the non-technical side of development.

Scott Mitchell

MSDN Magazine September 2008


Parallel LINQ: Running Queries On Multi-Core Processors

  

Use Parallel Language Integrated Query (PLINQ) to take advantage of multi-processor computers and the newer wave of multi-core processors.

Joe Duffy and Ed Essey

MSDN Magazine October 2007


Linq getting data from field on record

  

Hello,

   I would assume this is possiable but I cannot seem to find it anywhere. I just one the contents of a single field, I don't see why I have to return the how

record to get get that information, here is my current code, how can I make this better without returning the entire record, for just getting contents of one field.


var patternrecord = storedb.Patterns_Table.Single(a => a.Pattern_GUID == id);
PMEDIA.Pattern_Key = patternrecord.Pattern_Key;


Linq join fields for return data

  

Hello,
  how would I join fields together?

           return (from c in storedb.Product_Categories

                         where c.Category_Name.Contains(searchText)
                         orderby c.Category_Name
                         select new {
                                    c.Cat_GUID,
                                    c.Category_Key && " ;" && c.Category_Name // HOW CAN I DO THIS.....
                          

Time Difference in Linq queries

  

Hi All,

 

I have my Linq query in which i need to find time difference(not days difference).

The field in database is datetime.

Dim ldtToday As DateTime = TimeOfDay

Dim SR_RM_InnerJoin = From SR In lcntxRT60Entities.RtSReports _

Join RM In lcntxRT60Entities.RtRMaster On SR.RtRMaster.ReportID Equals RM.ReportID _

Select SR, RM _

Update field Linq

  
HelloI want to update one field of one record using linq. I use below codeDim p1 = (From p In db.Products_          Where p.ProductID= 1320 _                 Select p).Single        p1.CategoryID= p1.CategoryID+ 1        db.SubmitChanges()The issue is above query first execute select command and then Update command. and then update all fields of selected record. and this cause overflow to DB.I need to only update one field value. How Coudl I get below sql command. (only update one field)update Productsset CategoryID= CategoryID+ 1where ProductID=1320

Field method missing with LINQ query

  
H, I want to access the data from datatable object. When i trying to get the fieldslist usng "Field" method. But I could not find the method with my table object.  Eventhoguh i forcibly write a method and trying to access the fields, It is giving the below error for the first join in query. Rest of the lines are fine. What is the reason behind it. The errro: "Error 2 'LINQ2DB.SP_VS_OP' does not contain a definition for 'Field' and the best extension method overload 'System.Data.DataRowExtensions.Field<T>(System.Data.DataRow, string)' has some invalid arguments" What is the meaningof the error. Shall i do any other changes in the query line?                         var QueryChnl = from oSPOP in SPOP.AsEnumerable()                        join oDiscChannel in DiscChannel.AsEnumerable() on oSPOP.Field<int>("spid") equals oDiscChannel.Field<int>("SPID")                        join oChannel in Channel.AsEnumerable() on oDiscChannel.Field<in

Get Distinct value from a Group-Join syntax Linq

  
Hello,I have this group-join syntax but I couldn't get the distinct value from the relational tables below.Table_1key_1 t1_value1     Food2     Sports3     Leisure 4     Trip5     ZooTable_2key_2   key_1  t2_boolean15        1          True16        1          True17        1          True18        2          True19        2          True20        2          Falsedesire result:FoodSports            Dim c = (From t1 In dbContext_Table_1 _                                     Group Join GroupTable In _db.Table_2 On GroupTable.key_1 Equals t1.key_1 Into Group 

LINQ left outer join question

  
I can do this in other ways, but am looking for the "LINQ" way of doing this: Table1: People (PersonId,SchoolId)Table2: AssignedPeople (PersonId,SchoolId,RoomId) I want to select the people in Table1 within a particular SchoolId that are not in the assignedPeople table (in a particular Room).  The SQL is: select p.* from people p left outer join assignedpeople ap on p.PersonId=ap.Person and p.SchoolId=ap.SchoolIdand ap.RoomId=@roomId where p.SchoolId=@SchoolId and ap.PersonId is null I tried this LINQ (VB,NET):dim SchoolID as guid=...dim RoomID as guid=... (from p in dc.people where p.SchoolId=SchoolIdgroup join ap in dc.AssignedPeopleon p.PersonId equals ap.PersonId and p.SchoolId equals ap.SchoolId into groupfrom g in group.DefaultIfEmptywhere g.RoomID = nothing) but I can't get the ap.RoomId=@roomId part into the right place, should be something like:group join (from ap in dc.AssignedPeople where ap.RoomId=RoomId) Any help would be appreciated,Reuven

LINQ-to-SQL: How do you join more than 2 tables?

  
Hi there, I was trying to find out how I can join more than 2 tables using the LINQ-to-SQL syntax. For instance, joining 2 tables in SQL:  SELECT * FROM Table1 AS T1 INNER JOIN Table2 AS T2 ON T1.Key=T2.Column1WHERE T2.Key='17'; can be expressed as: var Result = from T1 in DbContext.Table1 join T2 in DbContext.Table2 on T1.Key equals T2.ForeignKey where T2.Key=17 select new { T1, T2 }; But how would I join 3 or more tables using LINQ? For example: SELECT * FROM (Table1 AS T1 INNER JOIN Table2 AS T2 ON T1.Key=T2.Column1) INNER JOIN Table3 AS T3 ON T3.Key=T2.Column2 WHERE T2.Key='37'; I've been searching and experimenting and I cannot seem to find any informraiton on this. One example I found involves putting the result for the frist join into a temp object, and then performing the second join. I'm not sure performance-wise if that's the same as doing a 3-table join directly using a single SQL statement. Any help will be greatly appreciated! Thanks,- K.  

Left Outer Join in LINQ + Entities

  
HiI have found quite a bit of info on the net, but I can't get it to work. Here's the normal SQL query:SELECT cl.ID AS ClientID, cl.Name, cl.Surname, CLC1.PHONECODE + ' ' + CLC1.PHONENUMBER AS WorkNum, CLC2.PHONECODE + ' ' + CLC2.PHONENUMBER AS HomeNum, CLC3.PHONECODE + ' ' + CLC3.PHONENUMBER AS CellNum, CLC1.PREFERRED AS WorkNumPref, CLC2.PREFERRED AS HomeNumPref, CLC3.PREFERRED AS CellNumPref, veh.ID AS VehicleID, veh.MAKE, veh.MODEL, veh.YEAR, veh.REGNO, ws.ID AS WorkshopID, ws.JOBTYPE, ws.SERVICEADVISOR, ws.TIMEFINISHED, ws.TECHNICIAN, fs.ID as FollowupID, fs.TYPE, fs.DESCRIPTION, fs.SCHEDULEDATE, fs.WRONGNUMBERFLAG FROM CLIENTS AS cl LEFT OUTER JOIN CLIENTCONTACTNUMBERS AS CLC1 ON cl.ID = CLC1.CLIENTID AND CLC1.TYPE = 'W' LEFT OUTER JOIN CLIENTCONTACTNUMBERS AS CLC2 ON cl.ID = CLC2.CLIENTID AND CLC2.TYPE = 'H' LEFT OUTER JOIN CLIENTCONTACTNUMBERS AS CLC3 ON cl.ID = CLC3.CLIENTID AND CLC3.TYPE = 'C' INNER JOIN CLIENTVEHICLES AS clveh ON cl.ID = clveh.CLIENTID INNER JOIN VEHICLES AS veh ON clveh.VEHICLEID = veh.ID INNER JOIN WSBOOKINGS AS ws ON clveh.ID = ws.CLIENTVEHICLEID INNER JOIN FOLLOWUPSCHEDULE AS fs ON fs.WSBOOKINGID = ws.ID WHERE fs.ID = 2 There is a multiple join between CLIENTS and CLIENTCONTACTNUMBERS so it would return a single row of data. If you were to do a normal join on CLIENTS and C

left outer join linq

  
 Hi   I try to get this exsisting linq query to use a left outer join without success, can anyone show me how its supposed to be?   Dim product = (From f In db.tbl_Formats _ Join p In db.tbl_Products On f.FormatID Equals p.FormatID Where p.NodeId = iNodeID _ Select p, f.FormatName).SingleOrDefault   The FormatID is not always present and I therefore need a left outer join on the Formats table.   Best Regards

SQL - Join Tables on Column Name and Row Field Value

  

Hello,

I have two SQL tables (SQL 2005) that I need to join but am in need of some assistance. Essentially I need to join a column name with row field values.

The first table contains the following columns

  • Loan ID
  • SSN
  • Ord_SignedApp
  • Ord_Title
  • Ord_Reg
  • Ord_Name

The second table contains the following columns

  • Item
  • Ord

However, the rows in the second table for the Ord column contain the following values:

  • Ord_SignedApp
  • Ord_Title
  • Ord_Reg
  • Ord_Name

I need to join the row field value of the second table with the column name of the first table. I want to display the values of the respsective columns of table one (Ord_SignedApp, Ord_Title, Ord_Reg, Ord_Name) and place them in a new column. These values are represented as dates

Any assistance you can provide would be much appreciated.

Thank you for your help,

 

Allison

 


Asynchronously Load LINQ Queries/Repeaters in Sections with Web Service

  

Hello,

I'm trying to  figure out the best way to load my main page faster.  What I'd like to do is have the bare bones of the master page display right away and on the Default.aspx Page_Load, call some web services that would query the rest of the items, in chunks, and then display.  I have 3 or 4 queries, which would be the chunks I am talking about. 

How would I accomplish this?  I tried putting Update Panels around the repeaters, but that didn't make the page show any faster, and the page still only displayed once all the data was queried.

I found this article, http://msdn.microsoft.com/en-us/library/2e08f6yc.aspx.  Could I call a web service and return a Linq Query and populate a Repeater on Default.aspx?  Would I need an Update Panel around the Repeater still?

I also found this article, which was very interesting in that it parsed and returned the actual HTML to plug into the page, http://encosia.com/2008/02/05/boost-aspnet-performance-with-deferred-content-loading/

I've been reading both of these for a while to try to understand which may be the best method to proceed with.  I'd really appreciate any a

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend