Hi
i've just started reading up on PLINQ and find it fasinating.
I'm using NHib-Linq in my projects - does anyone know if there's any benefit/problems using PLINQ type queries with NHLinq?
w://
I am using LINQ expressions in my code
like this
var obj = Collection.Single(collection = (collection.ShortName.Equals("AAA")));
The problem is that this line works fine for me, no problems.
But when I upload the same executable to some remote machine with same 32 bit Windows XP. The code execution is just stopping at this line of source.
Can anyone help me.
Hi,
Is there any way to cache LINQto SQL queries by looking at the parameters that were previously passed and bypass the database all together?
I know L2S caches some database calls, but I'm looking for a permanant solution as in, even if the applciation restarts, that cache reloads and never asks the database again.
Are there any frameworks for C#?
Hi all,
i am having query for update the node value using Linq,
For example i am have to update
<Student>
<studentdetail>
<studentname>test</studentname>
<libraryid>hem001</libraryid>
</studentdetail>
</Student>
in above xml i want to change the value of Student name "test" ti something else like "Undertest"
regards
NewDev
How can i rewrite the below SQL query to its equivalent LINQ 2 SQL expression (both in C# and VB.NET)
SELECT t1.itemnmbr, t1.locncode,t1.bin,t2.Total
FROM IV00200 t1 (NOLOCK)
INNER JOIN
IV00112 t2 (NOLOCK)
ON t1.itemnmbr = t2.itemnmbr
AND t1.bin = t2.bin
AND t1.bin = 'MU7I336A80'
Reading about both Linqto SQL and Entity Framework I have developed the impression that EF is more suitable for apps that get data from multiple data sources.
But as I am reading about MVC2 models I see an example where EF is more loosely coupled with your data model.
If I have to add or remove some columns from a table then what is involved in updating my model or DAL with each of these implementations?
Hi All,
i would like to iterate over the items of a List<T>, except the first, preserving the order. Is there an elegant way to do it with LINQ using a statement like:
foreach (var item in list.Skip(1).TakeTheRest())
{....
I played around with TakeWhile , but was not successful. Probably there is also another, simple way of doing it?
I have multiple C# projects in a Visual Studio solution right now that will all use the same SQL Server database.
What is the proper way to share LINQ-to-SQL classes between projects?
I'm considering just copying the dmbl files into each project, but I think that may be too redundant. Is there a better way to approach this?
Can anyone answer me what are the differences of
Session.Query
Session.Linq and
Session.QueryOver
What I'm really interested in:
What would be supported in the future versions.
What should I start to use in a clean project.
Please tell me your thoughts about these three...
Thanks,
Zoltán
Using Linqto SQL:
if(!parentlist.childlist.Contains(row1))
parentlist.childlist.Add(row1);
else
How do I update the required childlist row with row1? Each row of the child list has a unique id.
parentlist implements IEnumerable and childlist is IList.
If I want to get a user that has the email address of '[email protected]', how do I pass that as a parameter in linq?
ie.:
var a = from u in Users
where u.Email = @email
Select u;
So this would be used in my method:
public static GetuserByEmail(string email)
Do I just pass in the variable or?
I have struggled converting this SQL statement toLINQto SQL VB.Net 9.0. I have used Linqer but no success. Any help would be appreciated
select t.TeeId,
t.DescriptionId,
t.[Description],
t.Rating,
t.Slope,
case when d.TotalHoles <> h.TotalHoles then 0
else 1 end [Status]
from dbo.CourseDescription d
inner join dbo.CourseTees t
on t.DescriptionId = d.DescriptionId
inner join (select TeeId, count(*) as TotalHoles
from dbo.CourseHoles
group by TeeId) h
on h.TeeId = t.TeeId
where d.CourseId = 1
If I have two tables; Drivers keyed by DriverId and Trips with foreign keys DriverId and CoDriverId, and I want to find all trips where a driver was either the driver or co-driver I could code this in Transact-SQL as
select d.DriverId, t.TripId
from Trips t inner join Drivers d
on t.DriverId = d.DriverId or t.CoDriverId = d.DriverId
How could this be coded as a LINQ query?
I am using VS2010 and C#
When I map/select my database tables with LINQto SQL I have to option to change the "member" propery, but when i delete the table (because I changed something in the schema for example) and add it again the member value gets "reset". Is it possible to set/override this member programmaticly, so that I dont have to change it by hand everytime
I mean the member option of
'<'Table Name="dbo.table1" Member="table1"
I would like to use Linq instead of below function :
Friend Function IsCollectionInTable2(ByVal apps As DataTable, ByVal collectionId As String) As Boolean
For Each row As DataRow In apps.Rows
If row("CollectionId").ToString = collectionId Then Return True
Next
Return False
End Function
The best I can do is below:
Friend Function IsCollectionInTable(ByVal apps As DataTable, ByVal collectionId As String) As Boolean
Return (From row In apps.AsEnumerable()
Where (row.Field(Of String)("CollectionId") = collectionId)
Select row.Field(Of String)("CollectionId")).Count > 0
End Function
I would like to use Exists or Any in above function. Performance could be an issue,
I'd like to do the equivalent of the following in LINQ, but I can't figure out how:
IEnumerable<Item> items = GetItems();
items.ForEach(i => i.DoStuff());
What is the real syntax?
The folloqing is the excpetion I am getting
The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type.
below is my LINQ Statement where QuestionId is the primary key in my table
var questionViewsData = from questionViews in objDc.SC_QuestionsViews
join questions in objDc.SC_Questions
on questionViews.QuestionId equals questions.QuestionId into qs
from questions in qs.DefaultIfEmpty()
where questionViews.CreatedDate.Date == new DateTime(2010, 4,27)
select new
{
Selected =(questions == null ?-1:questions.QuestionId),
QuestioinTitle = questions.Title,
VotesCount = questions.VotesCount
};
Let me know how to resolve this
I'm looking for the full list of supported linq extension methods that are compatible with WCF Data Services.
By trial and error I've found First() and Single() aren't supported, any others?
This gives me a pretty good idea of whats supported, I just don't know whats actually translated via the IQueryProvider.
Hi,
I had asked this question
http://stackoverflow.com/questions/2442149/adding-more-attributes-to-linq-to-sql-entity
Now, when I add Browsable attribute to generated entity in designer,it works.But,when I use the MetaDataType approach,and add Browsable attribute in partial class,it does not work
"I added a MetaDataType class, and added browsable attribute to property,but seems to have no effect"
I have a scenario where I would want a plugin to construct a LINQ (to objects) query, send it across an appdomain and then apply and run it against a collection of my choosing
Is it possible, how?
If not, perhaps I could send a whole method (interface) across the appdomain and run it against the data on the appside? The main thing is that I want the data to reside in the CurrentDomain and the logic for operating on it in the plugin so I don't have to send the data across the boundary...
Here's the query i'm trying to convert into Linq:
SELECT R.Code,
R.FlightNumber,
S.[Date],
S.Station,
R.Liters,
SUM(R.Liters) OVER (PARTITION BY Year([Date]), Month([Date]), Day([Date])) AS Total_Liters
FROM S INNER JOIN
R ON S.ID = R.SID
WHERE (R.Code = 'AC')
AND FlightNumber = '124'
GROUP BY Station, Code, FlightNumber, [Date], Liter
ORDER BY R.FlightNumber, [Date]
Thanks for any help.
I need to know if the List I am working with contains only some specific values.
var list = new List<string> { "First", "Second", "Third" };
If I want to know if the List contain at least one item with the value "First" I use the Any keyword:
var result = list.Any(l => l == "First");
But how I can write a Linq expression that will return true/false only if the List contains "First" and "Second" values?
How do I retrieve all elements after the first one starting with a "-" using linq?
var arr = new[] {"-s1", "-s2", "va", "-s3", "va2", "va3"};
var allElementsAfterVA = from a in arr where ???? select a;
I want allElementsAfterVA to be "-s3", "va2", "va3"
Im using linq-sql .I have 3 tables. e.g
Project, People and a ProjectsPeople(fk's ProjectID and PeopleID) (junction) Table.
given a set of peopleIDArray (an array of ints as people ID's)
how can i get only Projects that have atleast one of the peopleId's associated with them?
i.e there will be atleast one (may be more) record in the ProjectsPeople table that will have a ProjectId and an id from the peopleIDArray )
thanks
Hi All,
i am trying to figure out how to write a linq query that will return a child collections "name" property as a string.
I have a BO that has a "options" property where the options are the "name" property of each option in an "order" object.
I would like the result to look something like
order.id = 12312
order.date = 12/03/10
order.options = "Option 1 Name, Option 2 Name, Option 3 Name"
I hope this makes sense. thanks for any and all help!