I have been playing with the Linq to Sql and i was wondering if it was possible to get a single result out? for example, i have the following:
using(DataClassContext context = new DataClassContext())
{
var customer = from c in context.table
where c.ID = textboxvalue
select c;
}
And with this i nee...
I am using LINQ to SQl and using TransactionScopre I am inserting the data in SQL .
_context.tblDataContainer.InsertOnSubmit(migrationData);
using (TransactionScope ts = new TransactionScope())
{
_context.SubmitChanges();
ts.Complete();
}
doing this, does linq execute any delete statements on SQL. i have checked using context...
Hi folks,
I've got the following Linq2Sql and it's doing more than one round trip for my 'SELECT' statement. I'm not sure why. First the code, then the explanation:-
from p in db.Questions
select new Models.Question
{
Title = p.Title,
TagList = (from t in p.QuestionTags
select t.Tag.Name).ToList()
}
Now the dat...
I am trying to convert some of my stored procedures to Linq and am having problems with the following Transact-Sql statement:
Select
Year(p.StartDate) As Year,
(Select Sum(t.Units) From Time t Where Year(t.TransactionDate) = Year(p.StartDate)) As Hours,
(Select Sum(i.Price) From Invoice i Where Year(i.CreatedDate) = Year(p....
Normally when you update an object in linq2sql you get the object from a datacontext and use the same datacontext to save the object, right?
What's the best way to update a object that hasn't been retreived by that datacontext that you use to perform the save operation, i.e. I'm using flourinefx to pass data between flex and asp.net and...
We have followed the approach below to get the data from multiple results using LINQ To SQL
CREATE PROCEDURE dbo.GetPostByID
(
@PostID int
)
AS
SELECT *
FROM Posts AS p
WHERE p.PostID = @PostID
SELECT c.*
FROM Categories AS c
JOIN PostCategories AS pc
ON (pc.CategoryID = c...
I need to represent inheritance like Person/Student. How do you do that in LInqToSql?
...
I have three tables like that:
Articles
IdArticle
Title
Content
Tags
IdTag
TagName
ContentTag
IdContentTag
Idtag
IdContent
When user in my site write an article with adding tags and submit, I want to save it to tables above.
In traditional ways, I used to use transaction and I could do it. But How can I do it by using linq to sql?
...
Hi,
I am trying to understand difference between those two and really need a explanatory simple example for them.
Thanks in advance..
...
To simplify my current situation lets say I have 2 tables (legacy so can't touch the schema to play better with Linq)
node
Columns: key_field1, key_field2, [lots of other fields]
node_children
Columns: parent_key_field1, parent_key_field2, child_key_field1, child_key_field2
node_children is similar to the has_and_belongs_to_many join...
I'm playing around with some Linq-SQL stuff, doing something like this:
var foo = from f in db.Foo where f.Bar > 5 select f;
which is all fine and dandy, and I know I can also do this:
var foo = from f in db.Foo where f.Bar > 5 select new { f.Bar, f.Baz };
What I want to know, is can I factor out the select part of that query, if I...
I am having an issue with linq updating in linqtosql
from the code below
Dim lqPatientTable As New lqHospitalDataContext
Dim strPatientId As String
strPatientId = Me.ucboPatientInfo.SelectedRow.Cells(5).Value
Dim lqPatientName = (From lqp In lqPatientTable.Patients _
Where lqp.PatientID = strPa...
This is a brief description of my db. You have issues which have categories. I have various queries that get issues based on all sorts of criteria, but that's not important to the question.
I want to be able to take a list of issues I have queried, lets say for example, that occured yesterday and group them by category.
I have a metho...
I have several service classes that have static methods and offer a service to the rest of my program. Most of these services involve accessing an instance of SqlDataContext (linq2sql).
First I tried instantiating this connection as a static private member per service class.
This works, but it also generates a bunch of lock ups, delays ...
Hey!
I am having some issues with using the OrderBy extension method on a LINQ query when it is operating on an enum type. I have created a regular DataContext using visual studio by simply dragging and dropping everything onto the designer. I have then created seperate entity models, which are simply POCO's, and I have used a repositor...
I have the follow Linq query ... which executes correctly:
from t in Tasks
where LookupTaskStarted(t.TaskId) == true
select new
{
t.TaskId,
t.Number,
Started = LookupTaskStarted(t.TaskId)
}
Is there anyway to create this as a property on the Linq-To-Sql class? Or do I always have to reference it like this?
...
I'm having a little bit of trouble understanding what the problem is here. I have a bit of code that pulls records from a database using LINQ and puts them into an object which is cast into an interface. It looks a bit like this:
public IEnumerable<ISomeObject> query()
{
return from a in dc.SomeTable
select new SomeObje...
I need to add "Next" and "Previous" links to a Web page displaying messages in date order. A SQL table holds the MessageNumber, Subject and Date. Currently I am using a stored procedure that uses the ROW_NUMBER function:
with MessageList AS
(
select msg_num,
row_number() over (order by msg_date) as rownum
from tblHeaders)
SELECT
...
In the following code doesn't work as
public void Foo()
{
CompanyDataContext db = new CompanyDataContext();
Client client = (select c from db.Clients ....).Single();
Bar(client);
}
public void Bar(Client client)
{
CompanyDataContext db = new CompanyDataContext();
db.Client.Attach(client);
client.SomeValue = "foo";
...
This one has been stumping me for a while. But I'm no expert. This is a bit long...
I have a WinForms app with an Outlook style UI. That it to say there is a bar on the left hand pane that allows you to select a 'screen' which is a WinForms control, say the customer screen, and on the right hand pane there will appear a list of custo...