How long could DataContext in EF and Linq2Sql live?
Could I store DataContext for a long time? What would be with Connection? ...
Could I store DataContext for a long time? What would be with Connection? ...
I'm using SQL Server 2005 express I have a datetime field in a table witch contains date and time. I want to select distinct the dates from the table ignoring the time part. I used this code but the order by is ignored ! (the generated sql doesn't contain order by) : var dates = (from c in db.Comments ord...
ExecuteQuery() method returns an IEnumerable but is there a way to make it return IQueryable? ...
If so, where do I put the Table[...] { } Object declarations? ...
Suppose I have employee and department table, employee has foreign key departmentID that is primary of department table. I use following code to get a single instance of an entity based on Linq to SQL: db.Employee.SingleOrDefault(e => e.empid == id); but I want to get the instance of department at the same time. How to write linq for t...
I'm with a very strange problem. I've a table with more than 800.000 records and 2GB mdf Database. When I try to get the last records: I'm only getting the records until one month ago, the last ones doesn't show up. Dim Items = From Item In DB.Items _ Where Item.CatID = CatID _ Order By Item.PubDate Descending ...
I was working with a simple entity class with LINQ to SQL (SQL Server 2005 SP3 x64). [Table( Name="TBL_REGISTRATION" )] public sealed class Registration : IDataErrorInfo { [Column( Name = "TBL_REGISTRATION_PK", IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert )] public Guid RegistrationID { get; private s...
Hi folks, I've got some tables in my Linq2Sql designer (in Visual Studio 2008). Works great. Now, I just tried dropping in a View onto the designer. It dropped on there ok, but there's NO foreign keys/associations. hmm. Ok, so then I tried to manually add an association between the View and a parent table. That worked .. but when i ...
I created a standard ASP.NET MVC project and then added a SQL Express database in the App_Data folder. The connection string is recorded into the web.config file. I then created a LINQ to SQL data model for the database. I want to test the data model from my Test project but I don't know how to go about this correctly because I am using ...
I am having an error: Error 2 'int[]' does not contain a definition for 'Contains' and the best extension method overload 'System.Linq.Enumerable.Contains(System.Collections.Generic.IEnumerable, TSource)' has some invalid arguments This is my code: public partial class mymymy : System.Web.UI.Page { int[] validType = { 2, 3, 4, 5, ...
Hey all. I'm not sure how I could express the following query in C# using Linq to SQL. Here is a short snippet of the pure SQL: select t1.WholesalerID, t1.RetailerID, sum(t1.Col1) as 'Column 1', sum(t2.Col1) as 'Other Column 1', (sum(t1.Col1) - sum(t2.Col1)) as 'Column 1 Difference', sum(t1.Col2) as 'Column 2', sum...
Ok - I have two tables in the database, employees and companies. Here are the basic schemas for each Table Companies CompanyID - GUID - PK CompanyName - NVarChar(100) Other Descriptive Fields.... Table Employees EmployeeID - GUID - PK CompanyID - GUID - FK Employee Descriptive Fields... So now I have a one to many relationship as ea...
I've manually created some classes in the Linq-to-sql designer and when looking in the xx.designer.cs file the class doesn't implement INotifyPropertyChanged interface. This works if I create the entity by dragging from the server explorer. Does anyone know why this is and if I am doing something wrong or if there is somewhere to set...
For eaxmple, LINQ to SQL is sending the following: exec sp_executesql N'SELECT [t0].[HomeID], [t0].[Bedrooms], [t0].[ImageURL], [t0].[Price], [t0].[Available], [t0].[Description] FROM [dbo].[Homes] AS [t0] WHERE ([t0].[Description] LIKE @p0) AND ([t0].[Available] = @p1) AND ([t0].[Price] >= @p2) AND ([t0]...
If I have a sql table that contains ProductID Price Date and I wish to find the latest price for a given date. In Sql I can do something like ` Select * from ( select ROW_NUMBER() OVER (PARTITION BY ProductID ORDER BY Date DESC) AS row_number, ProductID, Date, Price from ProductPrices where date < @targetDate ) tempTable whe...
Can I make this type of SQL query on LINQ to SQL? (this query is only a example) select * from orders as o left outer join (select * from ordersdetail where status = 'A') as od on o.id = od.orderid What I need is how can I put a subquery inside de "from" statement. Thanks ...
I am trying to bind a Linq to Sql object to a Repeater object and then update my DataSource. My question is, can binding persist, or do you have to use the CommandArgument to retrieve the record and FindControl to get the updated values everytime? If the former is the case, will someone please provide an example? ...
Possible Duplicate: LINQ to SQL: Return anonymous type? I have a standard LINQ to SQL query, which returns the data as an anonymous type (containing about 6 columns of data of various datatypes). I would like to make this returned object available to other parts of the program, either by returning it to the method-caller, or by...
Hi, I'm trying to get LinqPad use my dbml model so I could analyze a query from my source code. I've set the DataContext to "Custom LINQ to SQL DataContext", and all the necessary settings, unfortunately even with the simplest query I get an error : QUERY: from m in Linia select m ERROR: Could not find an implementation of the query pa...
In classic ASP we had the record set object. With ADO.Net we had the datatable. Both were simple .Net objects that could be moved around easily. What is the equivalent for using LINQ To SQL? Most examples show "var" being used, however, this seems completely non-oo as you can't move a var around (without a cast hack). My understandi...