I'm lost in linq-land, trying to turn this SQL (which give the results I need) into something that works in linq / C#. The result will end up in a SelectList.
select Agencies.AgencyName, Agencies.AgencyId
from Agencies
where Agencies.Active = 1 and Agencies.AgencyId not in (
select distinct Agencies.AgencyId
from Agencies, AgenciesD...
We have many clients using our application, and each of them has their own, identically structured database on our MS SQL Server. We also have a central database for information that is invariant and therefore shared among all the clients, such as the USPS ZIP Code database. Each client database has a view to these tables, like so:
cr...
In our code we have:
public interface ILogMagazine
{
string Text { get; set; }
DateTime DateAndTime { get; set; }
string DetailMessage { get; set; }
}
SimpleDataContext: DataContext
{
public Table<ILogMagazine> LogMagaines
{
get { return GetTable<ILogMagazine>(); }
}
}
We try to:
DataContext db = new SimpleDataContext...
Suppose I have linq expression q, then I want to add a sort to this query:
q = q.OrderBy(p => p.Total);
but for sort, there is desc/asc option for SQL, how to add it in above linq expression?
...
This may just be a yes or no type of question but here goes anyway...
From all (well most) of the examples that I've seen for using mvc, it appears that method for creating the dbml file is just drop the entire schema of the database into it and let it autogenerate all of the linq to sql goodness. It appears that you just need one of t...
Hi
I'm creating my first linq based project. The DAL consists of LinqToSQL classes. And the logic layer is just another DLL for keeping it simple.
I wanted to know how do I pass the var object (result of select query) from Login Layer to Presentation Layer?
Should I write my own DTO layer between Login layer and Presentation Layer to ...
I have been using LINQ to query my POCO objects for some time, but I have not yet tried LINQ to SQL. I assume that LINQ to SQL queries are somehow converted to equivalent SQL queries and, given this, I am wondering if that affects the way LINQ to SQL queries are or should be written.
Are there any significant differences between LINQ to...
I am currently playing around with Silverlight3, C# and LinqToSQL .
I have build up a database on a SQLExpress Server with some tables for example:
Employees ( Id, Name, DepartmentId, TimeStamp )
Departments ( Id, Name, TimeStamp )
The Id fields are VarChar(50), the Name Fields are VarChar(100) and the TimeStamp fields are of type time...
In normal (not compiled) Linq to Sql queries you can extract the SQLCommand from the IQueryable via the following code:
SqlCommand cmd = (SqlCommand)table.Context.GetCommand(query);
Is it possible to do the same for a compiled query?
The following code provides me with a delegate to a compiled query:
private static readonly ...
Hi,
So I have managed to get this query working
List<string> listStatus = new List<string>() ;
listStatus.add("Text1");
List<string> listMerchants = new List<string>() ;
listMerchants.add("Text2");
from item in db.vw_Dropship_OrderItems
where listStatus.Contains(item.StatusCode)
&& listMerchants....
Hi
I'm using Linq to sql to access an SQL Server.
I try to write all my database queries in a partial class so they can be accessed directly from the DataContext.
Now I would like to test the Data Context but I can't figure out the best way och doing that.
Bascially I need to test 3 things:
1. The queries return the correct data (no...
I have a basic SQL Table ( pKey INT, TransDate smallDateTime, Amount Float)
I simply want to emulate this SQL in LINQ
SELECT SUM(Amount) AS result
FROM dbo.Basic
WHERE TransDate >= @startDate
AND TransDate <= @EndDate
I have created the LINQ dbml for this and I can get basic query results for a date range
However I can't find the ri...
I am new to Linq to SQL, but I am surprised at the problems I am having updating a table.
From reading various sources I think the problem I get is a problem with the ORM mapping, but even so, given I am using VS 2008 and creating my dbml via a LINQ to SQL class, I do not expect this.
So what is happening is that when I update and/or ins...
Lets say I have 3 tables Posts, PostTags and Tags defining a many-to-many relationship. I want to get a lookup table that will give me all the Posts related to a given tag so I use the following code:
return dataContext.PostTags.ToLookup(pt => pt.Tag, pt => pt.Post);
In unit test all went fine but in the real application, it didn't wo...
I am finishing up a rewrite of a project management tool using ASP.NET MVC, LINQ2QL and the Repository design pattern. Pretty much following the NerdDinner example.
I have a class called Task that has a child list of TaskStages. For sake of this example the Stages are Ready, Under Development and Completed. I keep track of the current...
I have table A and Table B.
Table B contains two columns, Name and ID.
Table A contains several columns and a foreign key column pointing to B.ID called B_ID
On the client side, I have all the data I want to insert into Table A, except for B_ID. I have B.Name though.
using link to sql I need to retrieve the id in table B based on the v...
After I do an insert using linq to sql, can I get the Identity_scope value back if my table has an identity column?
...
Why can't I return as a new custom class (cms.bo.Site) which implements ISite?
public IQueryable<ISite> GetSites()
{
return (from site in Db.Sites select new cms.bo.Site(site.id, site.name));
}
...
Hi!
I'm having a linq to sql schema with a entity "Customers" as well as "Reports". Each customer has zero or more reports.
I want customers to have a LinkedList property, so that i easily can access the next and previous entity for each report.
What would be the best way, if any, to implement this using linq to sql?
Thanks
...
I'm going to rebuilt an existing moderate-scale web-app to be used for a supply-chain-management web-solution. The core would be around some Item\Site combination-records, Organization\User management, display Organization specific data (a dashboard with 2 levels of Grid) and a Drilldown which has some complex calculations for Item trans...