linq-to-sql

LINQ to SQL Math.Round Problem

Hello all, I'm having an issue with a query I wrote where for some reason the variable that I'm using to store a decimal value in returns 6 values after the decimal place (they're mostly 0). I have tried the following (and different combinations using Math.Round) with no luck. Sales = (from invhed in INVHEAD ......

whats the recommended Data access layer design pattern if i will apply ado entity frame work later?

I am creating a website and using Linq to SQl as a data access layer, and i am willing to make the website can work on both linq to sql and ado entity framework, without changing many things in the other layers: business logic layer or UI layer, Whats the recommended pattern to achieve this goal? can you explain in brief how to do that...

Problem with storing large files in database

I have used linq to sql to store files in a varbinary(max) field. Filestream is activated too, but when I try to store files with 400 or 500 MB I get this error: Exception of type 'System.OutOfMemoryException' was thrown My Code is: Dim ByteArray() As Byte = File.ReadAllBytes(OpenFileDialog1.FileName) Dim tb As New tb_1() tb._id = ...

Override LinqToSql class property

One of the fields in a table in my database stores string values delimited by '|'. Of course, when I generated a Linq data model from the table using the VS designer, a string property has been created for the mentioned field. I want to override that property so as to expose the stored values as a more convenient string array (splitting ...

In continue of questions "DB Schema for storing tagged records" -- how to select list of items with tags?

Good day! There are a lot of questions how to store tags in DB here on stackoverflow, I finally decide to use Toxi approach (items table, tags table and many-to-many intermediate table) http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html I want to display a list of 20-50 tagged items on a page each with list of it's tag...

Dynamic Linq.Table<TEntity> possible?

Hi Guys, I have 2 tables in a DB with very similar schemas that need to be queried in similar ways. I created a partial class for the linq entities, and then made the classes implement an interface, IEvent which defines all the properties with matching signatures that I need. All is good with that, I can cast my results to IQueryable an...

Linq to SQL: Get top 10 most ordered products

I'm wanting to grab the 10 most ordered products. My tables look similar to this: ProductProductID | ProductName OrderedProductProductID | OrderID OrderOrderID | DateOrdered At the moment I've got the following: return (from product in db.Products from orderedProduct in db.OrderedProducts where orderedProduct.Product...

Linq-to-SQL - Prevent where function running query against database

I have an IQueryable object which is the result of view (using a data model in Visual Studio). I want to apply an additional filter on the object, but I don't want it to go back to the database and run the query again with the additional where clause. The query takes several seconds to run so I'd like linq to simply filter the current ...

Periodic InvalidCastException and "The server failed to resume the transaction" with Linq

I see this on our stage system, after it has been up for 2-3 days. "The server failed to resume the transaction. Desc:39000000ef." (with desc:xxx increasing every time). The stack trace shows System.Data.SqlClient.SqlException: The server failed to resume the transaction. Desc:39000000ef. at System.Data.SqlClient.SqlConnection.OnErro...

How to relate Linq-To-Sql objects that are on different dbml diagrams?

I have two different dbml diagrams reflecting my Linq-To-SQL classes. (This is necessary, because they appear in different projects.) One of the objects in the one diagram needs an association with an object in the other diagram. How do I do it? ...

Tools and techniques to optimize a LINQ to SQL query

I have a couple of LINQ to SQL queries that I feel take a lot of time. What tool and techniques can I use to first find out: How long they take and if there is room for improvement? Find out what I can change and easily test if those changes are effective? Both tools, techniques and reading resources would be appreciated (ergo up-vot...

How to sort this Repository pattern and ASP.Net website architecture ?

I am Creating a new ASP.Net website "not mvc", and willing to make the data access layer has 2 versions, one using the Linq to Sql and another one using ad.net entity framework. Note: kigg is doing the same but in MVC website and too complex than i want. I learned that the best pattern to achieve my goal is using repository design patter...

LINQ Getting Started Problem

I am trying to build my hello-world program in LINQ. While executing the following code: (This is my LINQ to SQL class which is generated by VS2008.) #pragma warning disable 1591 //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime...

LINQ to SQl Class generated by VS2008

You can refer to this post. I am getting these Extensibility methods from VS2008 in my Linq to sql Entity. What are these auto generated extensibility methods good for? #region Extensibility Method Definitions partial void OnCreated(); partial void InsertPerson(Person instance); partial void UpdatePerson(Person instance); ...

c# linq update all records in database

hi, im trying to update all records in a sql table using the following code but no data is updated. does anyone know why? using (DataContext db = new DataContext()) { foreach (Item record in db.Items) { record.Description += "bla"; db.SubmitChanges(); } ...

Cannot save integer if it is empty.

Hi , i'm developing a form to insert data in the Database (SQlServer 2005) i use Linq to Sql in WPF; I have this database : Column Name Data Type Allow Null CODE ID Int(autoIncr) No BoatName Nvarchar(100) No BoatType Nvarchar(50) yes Numbe...

How do you map LINQ-to-SQL to your BLL classes?

I'm considering using LINQ-to-SQL for creating the DAL in my app. I normally create the DAL manually as I'm not a big fan of ORM (too much abstraction IMO) but I'm trying to save some time for an impatient client. My question is, how do you map the classes generated by LINQ-to-SQL to your BLL classes? Do you just add your code to the cl...

Partial Record Updates with Linq to SQL and MVC

Let's say I have a DB table with columns A and B and I've used the Visual Studio designer to create a Linq objects for this table. All fields are marked NOT NULL. Now I'm trying to edit this record using typical MVC form editing and model binding, but field B doesn't need to be editable, so I don't include it in the form. When the pos...

Unit Testing, Linq to SQL and working around the Data Context

Hi guys I have been looking at the following and it would appear that there are great benefits to be gained by using compiled queries... http://blogs.msdn.com/ricom/archive/2008/01/14/performance-quiz-13-linq-to-sql-compiled-query-cost-solution.aspx My problem is that I want to unit test my queries, but compiled queries need a concre...

Tables from 2 databases in one LINQ to SQL class

I want to include a table (Events) from another database in my LINQ to SQL class. How should I format the Data Source of that table? I have tried with IP.dbo.Events, IP.DatabaseName.dbo.Events and so on, but can not get it to work. The reason for all this is to select Events that a Client have attended. I have also tried to have the ...