linq-to-sql

LINQ Keyword search with orderby relevance based on count (LINQ to SQL)

This is what i have now as a very basic search: var Results = from p in dx.Listings select p; if (CategoryId > 0) Results = Results.Where(p => p.CategoryId == CategoryId); if (SuburbId > 0) Results = Results.Where(p => p.SuburbId == SuburbId); var OrderedResults = Results.OrderByDescending(p => p.ListingType); OrderedResults = OrderedRe...

Confusion between DTOs (linq2sql) and Class objects!

Hi there, i have been successfully working with linq2sql and the linq DTOs (the classes that are created by linq2sql) .... I am confused, i have the task of updating an old application and i can see that my DTOs will be used how they should be .... to transport date I am using the repository pattern so i am passing data from the repos...

VS2008, reporting via RDLC gives problem with 2nd level objects due to lazy load

I have a report that tries to show Order.Customer.Address.Line1 in a report. My Order object comes from a Linq2Sql DBML file. In the report i define it as Fields!Customer.Value.Address.Line1, but it comes out as "#Error". I then tried "touching" the variable before passing it to the RDLC, and lo-and-behold it suddenly worked. Apparen...

Joining tables in LINQ/SQL

I have below a collection of rows and each row consists of productid, unitid, countryid. I need to find the details for each row in the corresponding tables (products, units, country) for product - select product name, updatedby for unitid - select unit name , updatedby for countryid - select countryname, uploadby and returning...

Visual Studio keeps pegging the CPU for Intellisense as I type

Why would Visual Studio all of a sudden start using tons of CPU as it tries to implement Intellisense? I happen to be working with LINQ queries in VB.NET, but no idea if that's related or not. I've tried closing and reopening VS, but that has no effect. I'm not sure what else it might be related to, which makes researching it difficult a...

sql db design retrieving and submitting nominal values

I have a simple table with autoincrementing ID's and one text column. id(int), value(nvarchar) In another User table I have this ID as a foreign key. When i retrieve datat using Linq to Sql, I get the text value of the associated ID in one simple call. What about when I need to save into the User table when i only have the text and n...

Linq to SQL for a new project

Hi guys I am about to start a new project and am deciding what data access technology I will be using... I really like LINQ to SQL for a variety of reasons but should I start the new project using the Entity Framework instead?? I have this perception that the Entity Framework is more bloated and needlessly complicated, thus accounting...

Getting rows from a SQL table matching a dictionary using LINQ

I have the following code snippet: var matchingAuthors = from authors in DB.AuthorTable where m_authors.Keys.Contains(authors.AuthorId) select authors; foreach (AuthorTableEntry author in matchingAuthors) { .... } where m_authors is a Dictionary containing th...

LinQ XML mapping to a generic type

I´m trying to use an external XML file to map the output from a stored procedure into an instance of a class. The problem is that my class is of a generic type: public class MyValue<T> { public T Value { get; set; } } Searching through a lot of blogs an articles I've managed to get this: <?xml version="1.0" encoding="ut...

How could I make this query - LINQ to SQL ?

I have two tables like this Table Product ProductId - int <PK> ProductExpiry - TimeDate AlertOfExpiry - int ProductTypeId - int<Fk> Table ProductType ProudctTypeId - int <PK> Name - varchar(50) Now I want to get a list of products that will expire soon. So what I am trying to do is Say todays date is today August 24 and an expiry...

Simple Linq Join

Hello I have 3 related tables in my employee.dbml Emp dept Zone empId deptID ZoneID empName deptName ZoneType empage deptID empzone deptID Now how do I get ZoneType by passing empid in a query in linQ Please help ...

How to do joins in linq to sql?

Hi how do you do joins in linq to sql? I see they have the key word join and group join but what kind of joins are they? Left, Right, Cross, Inner? Also how do I select certain columns once I am done? Like Select Column1, Column2 From Table A; Either query or method syntax is fine. I still can't decide what I like better each seem...

inserting Data in to database from datagrid using Linq and Silverlight 3.0

How to insert new values in to datagrid from user and insert them in to the databse. I am using Linq to SQl and silvrelight 3.0 Thanks in advanece... ...

Where-clause in LINQ to SQL Sum() function

Consider the following snippet of code: // get number of sheep in DataTable by counting UID's Double n = DataTableContainingSheep.AsEnumerable().Sum(r => (Int32)r["sheepId"]) What I if want to count only the black sheep in the DataTable? Is there any way I can fit a select-clause into the Sum() function? ...

Update an EntitySet

I've got a set of LINQ-to-SQL entities which I've mapped to a view model. In this application a repository project is responsible for retrieving and storing view model objects. (So the entities are 'disconnected', new LTS entities are created from the specified view model objects and a DataContext is created per-request.) I've got a man...

Speed up LINQ inserts

Hi, I have a CSV file and I have to insert it into a SQL Server database. Is there a way to speed up the LINQ inserts? I've created a simple Repository method to save a record: public void SaveOffer(Offer offer) { Offer dbOffer = this.db.Offers.SingleOrDefault ( o => o.offer_id == offer.offer_id); ...

Database Architecture Question

I have a SQL Database that I am going to be interacting with via LINQ once built. It has a client who has (ignoring the others) two fkID fields to two tables. Class Country What I am trying to do is store a "Rules" table where the following happens: if the Class is 'A' and the Country is 'USA' then create rows 'RowsA' in...

How to log LINQ to SQL query without creating SQL connection

I want to use LINQ to SQL to query database. However in this particular situation all the queries have to go through a web service proxy, which in turn executes the query against the database. So the question becomes, how can I log the generated sql query without creating SQL connections. ...

LINQ to SQL INSERT Failing

I am experiencing a very frustrating issue when trying to insert a new record using LINQ to SQL. If I step through this code sometimes it inserts the new record but most of the time it doesn't. When it fails I seeing the following error. Cannot insert the value NULL into column 'Name', table 'EquipmentManufacturer'; column does ...

linq2sql using with dependency injection?

Hi Does anyone know how to have dependency injection work with linq2sql. Heres my situation.. I will explain it as best i can here. I have a base class which has a DBML (linq2sql) and classes etc .. This DBML is COMMON to more than 1 project.. Well each project has its own DBML but has all the tables etc that is in the common dbml i a...