linq-to-sql

SOLVED - XmlMappingSource.FromXml cannot load a mapping file generated by SqlMetal

Hi, I have a mapping file generated by SqlMetal, and when I try to instantiate a data context by passing that file, it gives me an exception which says something like "Root level node is invalid, line 1, position 1". I just put two files, a map file and a datacontext file, generated by SqlMetal into my WCF service project. Does anyon...

ASP.NET GridView Paging using Linq query as datasource

I am looking for a way to do paging with a GridView when i set the datasource at run time using a linq query. here is my code: ETDataContext etdc = new ETDataContext(); var accts = from a in etdc.ACCOUNTs orderby a.account_id select new { Account = a.account_id, aType...

LINQ to SQL Designer and the Geography datatype

Hi, I am having a few problems loading a table into the designer. I get the following error. One or more selected items contain a data type that is not supported by the designer Would I be correct in assuming it is the geography type used in the table that is causing this error? Any pointers much appreciated. ...

LINQ to SQL & EF

Possible Duplicate: Entity Framework vs LINQ to SQL Hi, What is the use LINQ to SQL though EF is supporting the SQL Server? Moreover, suggest me when to use LINQ to SQL and EF ? ...

Can LINQ To SQL used for other database (MySQl, Oracle, etc)

I have project creating with WPF and for database O/RM using LINQ to SQL, when i finish my project some people want to use MySQL as database, so can I change my Linq to MySQL without change any source code (maybe just change the connection string) Regards ...

Custom column in LinqServerModeDataSource

Hello, I have table in my database names User with fields: Id FirstName LasteName LoginName Now I would like to present this table in ASPxGridView using LinqServerModeDataSource. What I did is : <dxdtlnq:LinqServerModeDataSource ID="LinqServerModeDataSource1" runat="server" OnSelecting="LinqServerModeDataSource1_OnSelecting...

Grab result set and return value both from stored procedure in Linq to Sql

CREATE Procedure dbo.Ssample AS Select 1 as One , 2 as Two ,'3' as Three RETURN 2 --T-SQL way to execute declare @a int exec @a = dbo.Ssample select @a How can I retrieve the return value and the result set both in linq to sql. I would appreciate if anyone can give me the dbml markup as my designer file always get auto gener...

Return @@RowCount in LINQ to SQL INSERT

I am in the process of migrating some legacy code to LINQ to SQL and I am having some difficulty with the following Stored Procedure. BEGIN INSERT INTO tblCMOEncounterHeader ( submitter_organization_id, submission_date, begin_posting_date, end_posting_date, number_of_records_transmitted) ...

Using LINQ calling a sproc, how can I pass a var back from a method?

I have this method which worked for a while public string getSlotText(int slotID) { DataClasses1DataContext context = new DataClasses1DataContext(); var slotString = context.spGetSlotTextBySlotID(slotID); return slotString.ElementAt(0).slotText; } But what i really want now is something like public var getSlotText(int ...

Linq-To-SQL .ToList() operator

Is there a better way of doing this? I have a Linq-To-SQL query that I need to return objects defined by abstract interfaces (e.g. IList<IUser>) rather than concrete objects (e.g. List<User>). // get users from data context List<User> users; using (AbleridgeDataContext context = new AbleridgeDataContext()) { ...

Linq to SQL - Problem in Stored Procedure

I have storeProcesdure name called as prc_GetID, it's return value (ClientID) Here thr proc Code: Create PROCEDURE [dbo].[prc_GetID] (@ID VARCHAR(20)) AS SET NOCOUNT ON; SELECT ClientID FROM dbo.Clients WHERE [ID]=@ID I use above STORED PROCEDURE with linq to sql, here's Code, Public Class Form2 Dim dcClients As New dcDataContex...

SQL to LINQ compare 2 entities for changes - creating an audit trail

I am in the hypothetical phase of thinking of how to do something in code, so I have no concrete code examples yet. But, let's assume you have an entity type Person (with attributes such as first name, last name, DOB, etc.). When one goes to edit a person entity, you may only update one or two fields (possibly all, but usually not). T...

Count SQLClient database queries from ASP.NET app

I need to do some performance testing for an ASP.NET MVC application and specifically want to measure how many databsae queries each HTTP request results in. The data access layer is using LINQ-to-SQL. I'd like to be able to automate the tests so am looking for a good way to be able to do a before and after count of the number of SQL qu...

Is there a way to prevent from deadlocks (and what happens is one occurs and one is victimized)

Hi, I've tried to read an article on locks and deadlocks, and it just doesn't land, al the different kind of locks. We're running 2 different processes which try to edit records in the same table. The first process reads the new data and sends it to an external party and updates the status accordingly, the other one receives the receive...

Does Automapper supports Linq to entities (V1.1)

Hi Experts, Does AutoMapper supports linq to entities (framework 1.1). Is there any sample project available. Also using linq to SQL when I try convert from POCO to entity object, it fails saying AutomapperTest.Test.Account Help will be appreciated. Regards Parminder ...

Does an MVC 2 site with linqTOsql need repositories for each table object, or is there supposed to be one repository per site?

I've been working through a fantastic book (Pro ASP.net MVC 2 Framework, Steven Sanderson) and I am looking for clarification. In the book's e-commerce sample application uses linqTOsql and has just one table to hold product entries. Obviously, real world applications have many many tables. I am wondering if there is a separate reposit...

linq queries using if

Is it possible to do a query that contains an if? What I'd like to do is to select two certain columns based on the value of another column in the same table. So if the value of column1 is 0, I'd like to select custom1 and custom2, if it's 1, I'd like to select custom3 and custom4. ...

Convert anonymous type to strong type for grouping query?

I've pieced together some information from other posts but I'm stuck. The first part works fine. Basically I query the database using LINQ and then I loop through the results generating a report. Dim results As System.Linq.IQueryable(Of Bud900Reports.tblBud_CONNECT) If options.Type = reportType.Organization Then results = From...

How can I use LINQ to summarize this data--number of relationships grouped by the count of those relationships

I have a simple table like: | fkId | Item | --------------- | 1 | A | | 1 | B | | 1 | C | | 1 | D | | 2 | H | | 2 | I | | 3 | Y | | 3 | Z | I want a LINQ query that will first count the number of Item's per fkId, and then report the number of fkId's with a given Item-count. With the sa...

LINQ to SQL - method run for 2nd time does not return data changes that happened since 1st time

I have created a method in my data context that is mapped to a SQL stored procedure. The method is used in an ASP.NET application, and it is called twice in the lifecycle of a page. It returns the same single object in both cases (i.e. same primary key). After the 1st call some data changes are made, so on the 2nd call the stored proce...