I have a simple Entity Framework. For simplicity's sake I will transform the entity names to Northwind Like.
I have a IEnumerable Of Customer and Item Objects
I am trying to Create Orders which of course is made up (simplistically) of an Item and A Customer.
How can I go about creating and inserting these Orders?
-Hcane
...
This is not http://stackoverflow.com/questions/279401/sql-connection-pooling-and-audit-login-logout.
I've got a C# .NET 3.5 app that updates about 30K records on SQL 2008 on a local database.
The logic is it first checks to see if the record exists SingleOrDefault(p => p.stock=stock && p.number=number) and either adds the record or upd...
Hello,
I'm having an issue with LINQ-SQL not updating an XML column. I've run in debug and all values are correct, and when checking the table data I find out that the XML has not been updated.
Also any suggested reading on DataClassesDataContext vs DataContext?
Code:
///TEST LINQ MIHAI NEW XML
protected void testLINQ()
{
using...
Hi,
Is this query equivalent to a LEFT OUTER join?
//assuming that I have a parameter named 'invoiceId' of type int
from c in SupportCases
let invoice = c.Invoices.FirstOrDefault(i=> i.Id == invoiceId)
where (invoiceId == 0 || invoice != null)
select new
{
Id = c.Id
, InvoiceId = invoice == null ? 0 : invoice.Id
}
...
How would the following sql query look when translated to linq?
SELECT
myId, Count(myId)
FROM MyTable
GROUP BY myId
I've tried the following:
var q = from a in db.MyTable
group a by a.Id into g
let count = g.Count()
select new
{
Count = Id,
Key= g.Key
};
but it raises an exception on enumeration indicating that there is n...
I'm stuck with using a web service I have no control over and am trying to parse the XML returned by that service into a standard object.
A portion of the XML structure looks like this
<NO>
<L>Some text here </L>
<L>Some additional text here </L>
<L>Still more text here </L>
</NO>
In the end, I want to end up with one String...
What is the Linq equivalent to the map! or collect! method in Ruby?
a = [ "a", "b", "c", "d" ]
a.collect! {|x| x + "!" }
a #=> [ "a!", "b!", "c!", "d!" ]
I could do this by iterating over the collection with a foreach, but I was wondering if there was a more elegant Linq solution.
...
I have a web app that currently uses the current HttpContext to store a LINQ Data Context. The context is persisted for the current request, on a per user basis, per Rick Strahl's blog:
string ocKey = "ocm_" + HttpContext.Current.GetHashCode().ToString("x")
Thread.CurrentContext.ContextID.ToString();
if (!HttpContext.Current.Items.C...
I have a view in my database that produces ordered results, but when I run a Linq query over that view, the results are no longer ordered (at least, according to the foreach I use to iterate over the results, and according to the debugger). Is this a known difficulty with Linq, or am I missing something?
Update: my view, from SQL Serve...
Hi,
I think the best way to use Oracle with LINQ is to map the data base tables into the dbml file by hand. Am I right?
When I have done it, then what? How can i connect the data base with the dbml file?
...
//Feedback Check
var generalFeedbackQuery = from feedbackElements in xml.Elements("feedback")
select new
{
Feedback = feedbackElements.Element("general").Value,
PostiveFeedback = feedbackElements.Element("positive").Value,
...
Hi
This is a basic LINQ question.
In my RIA Services Application, I have a Family object with Contacts in a child list. This is a entity framework application.
I am wondering why when I select my fam the child list of Contacts are not loaded, well I know that it must because of lazy loading but how to I get my query to load the child...
I currently have 3 separate tables : Course, Category, and CourseCategory. CourseCategory is the connection only having the CourseID and CategoryId. I need a way in LINQ-to-SQL to add a Category property to Course objects that abstracts past the multiple tables. We need to change the application to only allow one category, but we don'...
I have rather a complex datastructure. The simple version looks like this:
public class Field
{
List<FieldRow> fieldRow;
//I want to write a delete that iterates and deletes given the key
//(Use Linq?)
public void DeleteByKey(int key)
{
//Do Remove
}
}
public class FieldRow
{
public int key;
}
Any help in impleme...
I am really confused about why an update is not taking place. This is very simple:
int goodID = 100;
DataContext db = new DataContext();
Schedule schedule = db.Schedules.Single(s => s.ID == goodID);
// this wont persist - WHY NOT?!
schedule.Email = txtEmail.Text;
// this does persist
schedule.NumberCourse...
Just wanted to check if there is way to do distinct by multiple columns. Thanks in advance!!!
BTW, I found a great LINQ extension here but need some guidance to use it for multiple columns
...
I want to create a MathML document from an expression tree using Linq to xml, but I cannot figure out how to use the MathML xml entities (such as and &InvisibleTimes):
When I try to create directly a XElement using
XElement xe = new XElement("mo", "&InvisibleTimes");
it justs escapes the ampersand (which is no good).
I also tried to ...
I have an XML File that I am processing using LINQ. I want to basically serialize the XML data into custom objects but don't know how.
Simplified XML
<Data>
<Group id="1">
<Child id="1"/>
<Child id="2"/>
<Child id="3"/>
</Group>
<Group id="2">
<Child id="1"/>
<Child id="2"/>
<Child id="3"/>...
How do I tell a LINQ data context to ignore either specific properties, or all readonly properties, when binding a result set to an object?
I am working with some T-SQL statements that are difficult to express using LINQ, so I'm using the ExecuteQuery method of the data context to pass the straight T-SQL to the database.
If my class T ...
I have two obects, A & B for this discussion. I can join these objects (tables) via a common relationship or foreign key. I am using linq to do this join and I only want to return ObjectA in my result set; however, I would like to update a property of ObejctA with data from ObjectB during the join so that the ObjectAs I get out of my ...