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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

how to work with temporry table in linq

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :ASP.Net

hi everybody

how can i work with temporary table in linq i mean temporary table in temp database that creat for each table ?is it possible or i must use sql store procedure because i use linq in my project?

View Complete Post

More Related Resource Links

LINQ Sorting After Goup w/ Table Reference


Having a little trouble here.  I am taking a table (Articles) and grouping all the results by the key that references another table (ArticleSectionCategories).  I then want to sort these results by the OrderBy field of the referenced table (ArticleSectionCategory.OrderBy).  This is what I am using right now but it is not working.  Any thoughts?


                var GroupedArticles = from A in DC.Articles
                                     where A.PackagesId == packageId
                                     group A by A.ArticleSectionCategoriesId into G
                                     select G.OrderBy(C => C.ArticleSectionCategory.OrderBy);


How we Update DataContext's Table Implicitly in Linq using .Net 3.5..?

Hi All.. My problem is i am working on Linq,as we know to use any table in linq we have to drag and drop it on our datacontext's Designer File,and at run time we got its value,till here no any problem,main point is if any changes in respective data source's schema has made ,then on datacontext we will not get that changes,for it we have to change this datacontext manually by by again drag and drop,it will not happen implicitly when this changes has been made on the data source. so please tell me how i solve this problem so that datacontext change implicitly without any over head  using .net 3.5 . 

linq - delete two tables not work

BurnbetDataContext db = new BurnbetDataContext(); var q = (from c in db.GetTable<tbl_Payment>() where c.UserId == "fc44c835-8e80-45ee-af84-68339a09c053" select c).Single<tbl_Payment>(); db.GetTable<tbl_Payment>().DeleteOnSubmit(q); db.SubmitChanges(); In App_Code I BurnbetDataContext.I have two tables and tbl_PaymentDetails tbl_PaymentAssociation is:Parent Child Class -->>> UserId UserId ClassData in Table tbl_PaymentDetails (child) does not delete.      

dynamic table name linq-to-sql query


I am writing a function in which i generate autocode in specific format i want to make this function generalize so that i send tablename and columnname  parameter and function return the next code. I am using linq to sql with MVC e.g. i want to make table name and column name dyanamic

from m in db.<tblnameparam> 
                       orderby m.<colnameparam> descending
                       select m.<colnameparam>

How can you work with listviews populated by linq to sql?



I'm having trouble with something that should be very simple.

I can populate a listview with a linq to sql control using the wizard, but actually need to do a more complicated query, so I eventually gave up as it wasn't at all obvious how I could add my own customer query (other than the very basic select statements through the wizard).

So I went the alternative route and wrote a linq to sql query and set that as the datasource.

The problem I now have is that I'm struggling to get edit functionality working, as although I've managed to get a button control into the form, I can't get it to make the listview go into edit mode for the selected record.

I suppose my first query is, was I right to go the way of creating my own linq to sql query in the codebehind or should I have done it in the linq to sql datasource some how?

Secondly, I've got the following code, that should bring up a message box when the button is clicked but it does not, can anyone explain why?

    Protected Sub ListView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles ListView1.ItemCommand
        If e.CommandName = "Edit" Then
        End If
    End Sub

The code for the butto

CTE doesn't work where derived table does

-- This produces: 0 rows affected
WITH upTasks(tStart, tEnd, BLineId, PlanId) AS 
 SELECT BLineId, tStart, tEnd, PlanId FROM Tasks_temp
 WHERE PlanId = 19 AND BLineId <= 8
UPDATE Baselines 
SET Baselines.tStart = upTasks.tStart, Baselines.tEnd = upTasks.tEnd
FROM upTasks 
WHERE Baselines.BLineId = upTasks.BLineId AND Baselines.PlanId = upTasks.PlanId

-- This produces: 8 rows affected
UPDATE Baselines 
SET Baselines.tStart = upTasks.tStart, Baselines.tEnd = upTasks.tEnd
FROM ( SELECT BLineId, tStart, tEnd, PlanId FROM Tasks_temp
 WHERE PlanId = 19 AND BLineId <= 8) AS upTasks
WHERE Baselines.BLineI

LINQ to Entity - using join for multiple table


I have my SQL query which needs to be conerted to Linq to Entity,

select pfr_sa.SID,pfr_sa.SourceGroupID,tx.txroll_cadaccountnumber,tx.txroll_StreetNumb

How to get Default value in table to work when NULL in DataSet

Is this possible? If the parameter value is NULL in DataSet, the default value is not assigned.

Junction table with Linq


Hi, I have a question about how to insert values into a junction-table with linq.

I have a class that makes all the insert/updates and delete actions, it also contains a method for submiting the changes to the database.

I have 2 tables that are connected with a junctiontable with their primary ID:s

Lets say that I want to insert some values into one of the tables. How do I in the best way insert data to the junctiontable ?

Should I lose the Save() Method and do submitchanges() in each of the methods instead?

join 3 table in LINQ



i use Default membership provider for my membership

i add a profile table for some more information from user and it related with UserId with aspnet_Users

to get data from my database i use  Entity Data Model

now i want to write a Linq to get data from all 3 tables

can you help me to know how to write this guerry



can sql queries work on the same form with Linq queries



I have a windows form with VB  and SQL database ,and i find that once i have written some Linq queries that the SQL queries do not work anymore . Is there any reaon for this and if so how can i overcome it?

THanks Rob


How to bind data from linq to html table without a single line of loop.




This is the above code i have worked using querysing and displaying the listitem with in  a simple html table. Here I am using foreach statement to bind items. How to bind the data to a simple html table using SharePoint linq without  a single line of loop.

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Linq;
using Microsoft.SharePoint.Linq;

namespace QuerystringProgramWithoutLoop.QuerystringProgramWithoutLoop
    public class QuerystringProgramWithoutLoop : WebPart
        string strTitle=string.Empty;
        string strStatus=string.Empty;
        protected override void Render(HtmlTextWriter writer)

DBCC SHRINKFILE: Page 4:11283400 could not be moved because it is a work table page.





I issued this command on Tempdb but it doesnot shrink the file.


dbcc shrinkfile (tempdev_3,1)





DBCC SHRINKFILE: Page 4:11283400 could not be moved because it is a work table page.



I have  checked that there are no tables associated with any user in tempdb. Any help is appreciated.




Help: populate Html.DropDownList from table data? [Linq to SQL model]


I have two tables, Users and Roles.  The roles table is a reference table for the different roles of my site (RoleId and RoleName columns). The Users table contains profile data for each user, including a RoleId column that is FK'd back to the Roles table [RoleId].

Both tables are in a Linq to SQL model.

I have an edit page created which lists all the profile values of a user.  The edit page inherits the User model.  One of the editable values is the RoleId field.  I want to set this up to be a drop-down list that contains items labeled using the RoleName column of the Roles table, and matched with values of RoleId.

How can I achieve this?

Adding data to table using linq to sql


Hi all, i am very new at this and are looking for some help. i have to tables, Question( Qid,question,answer,Cid ) and Category( Cid,category ), the primary keys are Qid and Cid, the Cid is a foreign key in Question, when i want to add a new question to Question i am choosing a category from a DropDownList controll, and if want to add a new category at the same time i have a TextBoks for it, i have create a Model, BLL and DAL classes, my problem is:

in the DAL class i want to add a new row to Question, but i need to check first if the object.category exsist in the table Category, if it does i want to get the Cid for it if it dosen't exist i want to create a new raw then get the Cid, this is my code: please finish my code with some explanaitions

public string add(Faq inFaq)
            using (var db = new DBClassDataContext())
                    var se = from Ca

VB.NET Linq - Multiple column Group By using Anonymous types does not work properly


I am attemping to do a multiple column group by in linq using VB.  I've followed a code sample i obtained at the following url:


the sample code is:

GroupBy - Multiple Columns

This sample uses Group By to group products by CategoryID and SupplierID.

Public Sub LinqToSqlGroupBy09()
    Dim categories = From p In db.Products _
                     Group By Key = New With {p.CategoryID, p.SupplierID} Into Group _
                     Select Key, Group

    ObjectDumper.Write(categories, 1)
End Sub

My code result though is not correct, as i am getting duplicates.   The first query is using the data which is stored in a datatable.  The second table pulls the data from a list of objects which i manually built in an effort to get closer to the Example provided above.

Dim listNamesWithSeverity = From myrow As DataRow In dt.Rows _

Pull RDA Table -> Upgrade Server 05 to 08 -> Push RDA Table : Will this work?

If I pull a table using RDA, then upgrade the SQL Server from 2005 to 2008, then push the RDA table back, will this work, or will it throw an error and the data lost? Has anyone done this before?
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