I have some views that I'd like to relate together in my Linq2Sql DBML file.
I've right clicked, selected "Add association" and manually created the associations from children to parents, for example:
Customer.TypeId -> CustomerTypes.Id
But I cannot do this in my code:
from c in Customers select c.Type.Name
Any clues? If the relat...
I'm accessing a database column where a phone number is stored as a varchar in the format +a-b:c where a = country code, b = phone number and c = extension. E.g. +44-07700123456:123
So I have a type that handles serialization along the lines of:
public struct PhoneNumber {
public PhoneNumber(string val) { /*...*/ }
public override...
I wanted to convert my existing stored procedures to LINQ-to-SQL Precompiled Dynamic SQL. Does anyone know of the best way to do this?
I mention precompiled as I believe I can get a performance increase - not the same as SPROC but similar, correct? Also with LINQ-to-SQL Precompiled Dynamic SQL, I get strongly typed fields, etc. Are thes...
How can I put the LINQ to SQL generated classes in a dedicated DAL project so that I can access it from various other projects in the same solution? I.e. so I can use one for Web, and one for Windows Forms?
...
Hello,
I have a table called Quiz that have these fields
id As Int
created As DateTime
header As Sring
body As String
fk_parent As int
url As String
All the items without parent key would be the question, and ones that have the parent key would be the answer. I am having the problem to get all the latest active questions (based both ...
I am trying to serialize some Linq objects using this code.
private byte[] GetSerializedObj(object o)
{
try
{
DataContractSerializer formatter = new DataContractSerializer(o.GetType());
MemoryStream memStream = new MemoryStream();
formatter.WriteObject(memStream, o);
return memStream.ToArray();
...
I would like to know what are the principal diferences between "ADO.NET Entitiy Data Model" and "Linq to SQL Classes"? What is the best choice to work with?
I couldn't find any document on the internet explaing that and everything I know is that we can use both, "almost", in the same way.
...
I spent this morning in trying to figure out where the system.linq.expressions namespace is. The following is what I did:
In VS 2008, Create a new C#/Smart Device/Windows Mobile 6 Professional SDK/.NET CF v3.5/Class Library
Used SqlMetal (in Program Files/Microsoft SDKs/Windows/v6.0A/Bin) to generate the data context.
Added the data co...
We're using sqlmetal to generate our DBML, run it through a transformation, then use sql metal to generate the DataContext classes -- additionally, I want to automatically generate some validation for the entities based on some metadata that we store in the database about each entity and it's attributes. For example, if an entity has wha...
Maybe a simple question, I'm trying to get a result from a table where the Name column contains all of an array of search terms. I'm creating a query and looping through my search strings, each time assigning the query = query.Where(...);. It appears that only the last term is being used, I supposed because I am attempting to restrict th...
Hi
I have lots of tables and some of them have many relationships with other tables. I noticed the tables that have one relationship I am able to do what it is shown in NerdDinner Chapter 1.
Dinner dinner = db.Dinners.Single(d => d.DinnerID == 1);
RSVP myRSVP = new RSVP();
myRSVP.AttendeeName = "ScottGu";
dinner.RSVPs.Add(myRSVP);
S...
Hello,
I have two tables Settlement and Violations.SettlementID is primary Key in Settlements table and foreign key in Violations.
In my dbml file I dragged and dropped both the tables and the association is set.
In my VB.net code when I try to insert records into db it is not giving option to add values Violation collection into Set...
Is there an equivalent of SQL's IN clause, in LinqToSql?
For example, how would the following query be done in LinqToSql:
select * from users
left join groups on groups.pkid
in (select group_id from user_group
where user_group.userid = users.userid)
...
What I need is such a simple, easy query, it blows me away how much work I've done just trying to do it in LINQ. In T-SQL, it would be:
SELECT I.InvoiceID, I.CustomerID, I.Amount AS AmountInvoiced,
I.Date AS InvoiceDate, ISNULL(SUM(P.Amount), 0) AS AmountPaid,
I.Amount - ISNULL(SUM(P.Amount), 0) AS AmountDue
FROM Invoices...
Hi,
Do you have to write update statements with Linq to SQL?
...
I am trying to figure out how to notify the user which field failed to validate.
I setup LINQ to SQL class datacontext to access a database from ASP.net pages. Since user input will be from by web interface forms and import from Excel files, i would like the write the validation logic in one place. The idea behind this is when i import f...
I will soon be beginning work on a project that (from the spec) reminds me a bit of StackOverflow. Basically, its a web app that has user-controlled content.
One of the features that's got me going around in circles in my mind is the version control. Here on StackOverflow, each question and answer can have multiple revisions. This is pr...
I have a table of customers. This table can be big, millions of rows. Every hour, I have a console app that goes through all the customers and updates another table with customer changes that occured in the last hour.
What I want to do is two things: (1) Have the console app (or SSIS package) be multi-threaded so that I can have a coup...
Can anyone LINQ the following SQL?
I've been on this for two hours now and am no closer to getting this than I was when I started.
SELECT ArticleId, sum(Amount) AS VoteCount
FROM ArticleVotes INNER JOIN
Votes ON ArticleVotes.voteId = Votes.id
GROUP BY ArticleVotes.articleId
ORDER BY VoteCount DESC
Tables as follows;
ArticleVotes: A...
Hi folks,
I'm used to loading some children results (for a parent result) using the LoadWith syntax. Works great. Is there a way I can limit these LoadWith results to the most recent 5 or something?
I've got some pseduo code with some inline comments to help explain what I'm trying to do...
Eg.
IList<Parent> results;
using (DataBas...