linq

Normalize or Denormalize: Store Contact Details (Phone Numbers) in separate Table? Search Performance?

Hello, I'm designing a database application which stores simple contact information (First/Last Name etc.) and I also have to store phone numbers. Besides phone numbers I have to store what they are for (mobile, business etc.) and possibly an additional comment for each. My first approach was to normalize and keep the phone numbers in ...

Sql Server 2005 and Linq Transactions

I'm having a problem with a transaction in linq-to-sql timing out after 30 seconds. Setting the CommandTimeout property on the DataContext does not seem to change the timeout. The error message I get is: "Timeout Expired. The timeout period elapsed prior to the completion of the operation or the server is not responding" Queries that...

Why can't I use a Linq query on a Visio Masters collection?

I am trying to do the following Linq query on a Visio Masters collection: List<string> allMasterNames = (from master in myStencil.Masters select master.NameU).ToList<string> I get the following error: Could not find an implementation of the query pattern for source type 'Microsoft.Office.Interop.Visio.Masters'. 'Select' not ...

Joining results from seperate API's together.

I have 2 seperate systems - a document management system and a sharepoint search server. Both systems have an api that I can use to search the data within them. Tthe same data may exist in both systems, so we much search both. What is the most efficient way (speed is very important) to search both api's at the same time and merge the r...

Writing SQL function with XQuery Parameters

Following on from one of the answers in this thread; http://stackoverflow.com/questions/214060/using-xquery-in-linq-to-sql/214435#214435 I'm trying to create a sql table function that will take parameters in order to perform queries on xml data. The function can then be consumed by a linq query. Issue's i'm having are ; If i take th...

Set foreign key value in business entity data model

hello, I have table SublocationTbl that have SubLocationName and LocationId(this field is foreign key from table LocationTbl), and I have business entity data model I know that the foreign key dosen't appear in the business entity my problrm is: how can I set the value of locationId when I need to add new subLocation? ...

IMultipleResults Using Custom Model & Repository

I'm following Steve Sanderson's example from this ASP.NET MVC book on creating a model by hand instead of using diagramming tools to do it for me. So in my model namespace I place a class called MySystemModel with something like the following in it [Table(Name="tblCC_Business")] public class Business { [Column(IsPrimaryKey=true, IsDb...

C# Asp.Net MVC - Combine Select Lists?!

I have these two methods below. One returns a list of manufacturers based on the handset ID and the other returns a list of Handsets based on the Handset ID (relationship via handset ID). How can I combine them to return one select list with the combined manufacturer handset value? (Bit new to MVC) SelectList GetManufacturers() { v...

Entity Framework Associations

Hi, I've created a Model with Entity Framework from three database tables: Agents AgentsGroups Groups AgentsGroups is a simple table with three columns: 1 id and two foreign keys linking Agents and Groups (every Agent can have multiple Groups). Pretty basic stuff. Entity Framework correctly recognizes the relationships between the ...

Select Multiple Fields from List in Linq

In ASP.NET C# I have a struct: public struct Data { public int item1; public int item2; public int category_id; public string category_name; } and I have a List of those. I want to select category_id and category_name, running a DISTINCT and finally an ORDERBY on category_name. Here's what I have now: List<Data> lis...

Can I execute a LINQ to SQL query from within a LINQ object?

I currently have a LINQ query implemented as a method of my DataContext class. This method calculates the permissions a user has for a page within a Wiki/CMS. What I'd like to do is relocate this method to the Page and User LINQ data objects. However, when I move this query to the individual data objects it executes using LINQ to Obje...

SQL to Linq Conversion.

I have sql as below SELECT Q.MaterialID AS MaterialID, Q.ProductID AS ProductID, QB.Quantity AS Quantity, Q.ParameterID AS ParameterID, SUM((Q.ParameterValue * Q.Quantity)/Q.TotalTonnes) AS ParameterValue FROM @Quality Q INNER JOIN @QuantityBreakdown QB ON ((Q.MaterialID = QB.MaterialID) OR (Q.MaterialID IS NULL AND QB.MaterialID...

How can I select XElements where Attribute ... (LINQ2XML)

How can I select the Value where id == id && key == key with Linq xml: <Localization> <Module id="Customers"> <CultureCode>de-DE</CultureCode> <Key>General</Key> <Value>Allgemeine Kunden</Value> </Module> <Module id="Contract"> <CultureCode>de-DE</CultureCode> <Key>General</Key> <Value>Allgemeine ...

VS2008: Make a non-LINQed website LINQed

Hi I've recently started playing around with ASP.NET and I was just about to connect to a database using LINQ, when I realised that you have to change a bunch of stuff in the project first if you created a normal web site project in Visual Studio 2008. All the information about LINQed projects in VS2008 that I have found start directly...

NHibernate Linq Session Management

I'm checking out Linq for NHibernate 2.1 to use in an ASP.NET MVC application and I am trying to figure out session management. As a first experiment I am trying to modify the SportsStore application from Pro ASP.NET MVC Framework. This sample app uses Linq to Sql so I thought it would be a good exercise. I have NHibernate 2.1 accessing ...

LINQ and paging with a listview

Hi, I have a page with a listview control and a datapager control. The listviews datasource is set programatically using this code: Dim dal as new dalDataContext Dim bookmarks = From data In dal.getData(userid) listview1.DataSource = bookmarks listview1.DataBind() When i test this page in a browser it comes up with the error: 'ListV...

NHibernate How do I query against an IList<string> property?

I am trying to query against an IList<string> property on one of my domain classes using NHibernate. Here is a simple example to demonstrate: public class Demo { public Demo() { this.Tags = new List<string>(); } public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual IL...

Linq to SQL SP parameters

I have a SP which I want to call from linq. The SP have 5 parameters but i only want to pass/need to 2 of them. how would I call the SP as when i go to add the parameters in code it wont build as it want all 5. ...

OrderBy and OrderByDescending are stable?

I am currently reading Pro LINQ c# 2008, and in page 87 the guy says OrderBy and OrderByDescending are stable. But he says exactly the opposite in page 96. It looks to me as he is referring to exactly the same functions, so I don't get it. Are they stable or not? ...

Best way to do ORM with Access DB as datasource

I've gone back and forth on this problem and can't seem to figure out the best way to do this. Here's the situation: Access database (3rd party product) with data I need in it, from a good number of tables (18 tables) Ideally, need to try to get records into strongly-typed objects somehow so I can query around with LINQ LINQ to SQL cl...