linq-to-sql

When I add a database table to a DBML file via LINQ to SQL, I get a slew of compiler errors.

Whenever I add a certain table to a DBML file via LINQ to SQL, I get 102 errors in my VB NET project. Some of the errors: Error 1 Attribute 'TableAttribute' cannot be applied multiple times. C:\Documents and Settings\zchoy\My Documents\Virtual EMS Deployment\Life And Death\Life And Death\ShearwaterEMS.designer.vb 74 2 EMS Rea...

Alternatives to LINQ To SQL on high loaded pages

To begin with, I LOVE LINQ TO SQL. It's so much easier to use than direct querying. But, there's one great problem: it doesn't work well on high loaded requests. I have some actions in my ASP.NET MVC project, that are called hundreds times every minute. I used to have LINQ to SQL there, but since the amount of requests is gigantic, LI...

Testing a (big) collection retrieved from a db

I'm currently doing integration testing on a database and I have the following sql statement: var date = DateTime.Parse("01-01-2010 20:30:00"); var result = datacontext.Repository<IObject>().Where(r => r.DateTime > date).First(); Assert.IsFalse(result.Finished); I need to test if the results retrieved from the statement, where the giv...

LINQ to SQL table naming

I am using VS2010 and C# When I map/select my database tables with LINQ to SQL I have to option to change the "member" propery, but when i delete the table (because I changed something in the schema for example) and add it again the member value gets "reset". Is it possible to set/override this member programmaticly, so that I dont have...

Repository vs Data Access

Hi guys In the context of the n-tier application, is there a difference between what you would consider your data access classes to be and your repositories? I tend to think yes but I just wanted to see what other thought. My thinking is that the job of the repository is just to contain and execute the raw query itself, where as the d...

Trying to get a single row (flattened) for a master detail table using LINQ to SQL

I have a Batch Table that has three columns ID, Name, Type and a CustomAttribute table that has three columns ID, ParentID, PropertyName and Value. The Select query is "Select Batch.ID, Batch.Name, CustomAttribute.PropertyName, CustomAttribute.Value from Batch, CustomAttribute where CustomAttribute.ParentID = Batch.ID This query will g...

Out-of-range Datetime issue using LINQtoSQL

This is really confusing me. Here is a snippet of my model: * SQL Server * Event ----- Id (int, PK) NOT NULL Title (varchar(100)) NULL LastModified (datetime) NULL EventDates ---------- Id (int, PK) NOT NULL StartDate (datetime) NULL EndDate (datetime) NULL * C# * Event ----- public int Id public string Title public DateTime LastM...

Entity Framework (4.0) how to exclude a related table.

I have just updated to using EF 4.0 where before i was using Linq 2 SQL. I have a query: var UserList = this.repository.GetUsers(); return Json(UserList, JsonRequestBehavior.AllowGet); This was generating an error: "A circular reference was detected while serializing an object of type" This prompted this code which worked f...

VB.NET LINQ to SQL Delete All Records

I am having problems with deleting all records in a table with VB.NET. I am using this code to delete all records in the Contacts table For Each contact In database.Contacts database.Contacts.DeleteOnSubmit(contact) Next But I get this error Can't perform Create, Update or Delete operations on 'Table...

how to use a generated dbml classes to deserialize xml via linq?

Hi, I have a complex data structure, which I boiled down in a dbml file with one class and 6 one-to-many relations. This data must also be read via xml. The xml structure is something like: <table id=1> <column 1></column 1> <column n></column n> <m-n table x> <column 1></column 1> </m-n table x> </table> where t...

I need to convert the result of a stored procedure in a dbml file to IQueryable to view a list in an MVC view

I have a MVC project that has a Linq to SQL dbml class. It is a table called Clients that houses client information. I can easily get the information to display in a View using the code I followed in Nerd Dinner but I have added a stored procedure to the dbml and it's result set is of IQueryable, not IQueryable. I need to convert IQue...

T-SQL generated from LINQ to SQL is missing a where clause

I have a DataContext object, called "CodeLookupAccessDataContext", that was generated through the Visual Studio LINQ to SQL class wizard. I extended the functionality of this object such that it exposes some methods to return results of LINQ to SQL queries. Here are the methods I have defined: public List<CompositeSIDMap> lookupCompos...

FirstOrDefault In F#

How to write FirstOrDefault Linq Query in F#? Can I use linq to sql in F# in totally? ...

Something wrong on my very first LINQ to SQL C# code

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Advanced_LinQ_Query { public partial class Form1 : Form { public Form1() { InitializeComponent(); } ...

An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

Ok the thing is that I am using asp.net mvc with linq to sql. I have a scenario where there are two tables group and features with many to many relationship with the third table groupfeatures. I have drag and drop all three table in the dbml file. The thing is that it runs fine with group but when I call the Feature things the above err...

Does it suck or not - Simple DAL with caching using Linq to SQL

I created a simple Caching Data Access Layer that has caching using the Enterprise Library Caching Application Block and also makes use of SQL Query Notification - therefore not supporting any queries which are not valid for query notification. Background: This was put in place after the application was developed in order to lighten the...

LINQ to SQL Web Application Best Practices

In my experience building web applications, I've always used a n-tier approach. A DAL that gets data from the db and populates the objects, and BLL that gets objects from the DAL and performs any business logic required on them, and the website that gets it's display data from the BLL. I've recently started learning LINQ, and most of th...

How to get particular column distinct in LINQ to SQL

I am having columns as category and songs in my table for each category. There are almost 10 songs and in total there are 7 categories such that it is tabled as category1 songCategory1a category1 songCategory1b category1 songCategory1c --- --- -- category2 songCategory2a category2 songCategory2b category2 songCategory2c --- --- --- cate...

Using LINQ to SQL with multiple databases

I am working on a new project and hoping to use LINQ to SQL for the data access but have come across the following issue. I need to have my application access 3 databases with similar but not the same table structure, for example Database1 and Database 2 has a table called tblCustomer with 2 columns CustomerKey and CustomerName Databa...

asp.net mvc checkbox hierarchy

I want to create a checkboxes hierarchy like this in mvc2.How would I be able to achieve this in the most simplest manner.I have done this with tree in traditional forms .Beside Each field there is a checkbox. If I want to Assign Manage User and Manage Feature to the Administrator I will checked the checkboxes press submit and then the f...