linq

An alternative to LinqToRDF, a library to bring Linq to RDF data?

LinqToRDF (http://code.google.com/p/linqtordf/) is a well known library to bring Linq to RDF data. But it is not active for nearly two years. So I am looking for an alternative. My basic requirement is providing basic Linq function with general RDF data sources. Commercial library is welcome also. Any suggestions are welcome. Ying ...

What is the purpose of LINQ's Expression.Quote method?

The MSDN documentation states: Expression.Quote Method Creates a UnaryExpression that represents an expression that has a constant value of type Expression. I've been able to build predicate expressions for use in LINQ queries by manually constructing them using the Expression class, but have never come across the need f...

Converting XElement to HTML string

I am performing XML Operations on an XHTML document utilizing Xml and Linq. When converting it back to a String for outputting to a browser, it renders script tags in their original provided form when creating the XElement as <script />. That prevents it being processed correctly by most browsers on the market. I would like to perform...

How can I solve "The query results cannot be enumerated more than once"?

if i try to write below codes : error return to me: The query results cannot be enumerated more than once public void StartTransaction() { using (var stockMovementCtx = new StockMovementCtxDataContext()) using (var scope = new TransactionScope()) { var stockMovementItems = f...

Specifying properties to be updated in linq query

Hi all. I want to be able to specify the properties to get populated/updated in the linq expression. Something in the following fashion: Proxy.UpdateEmployee(List<string> propertiesNames) Proxy.GetEmployee() //inside the method populate only certain properties The return values must be of known type(no anonymous types accepted). DLINQ...

Are there sequence-operator implementations in .NET 4.0?

With that I mean similar to the Linq join, group, distinct, etc. only working on sequences of values, not collections. The difference between a sequence and a collection is that a sequence might be infinite in length, whereas a collection is finite. Let me give you an example: var c1 = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; var c2 =...

linq order by problem, depending on Language..

String[] a = new String[] { "NIKE", "한글","adidas","한글Korean" }; I like to order the array, the 한글 is first if I just order without options. the English String is always on top. how can I do this? and sorry about my horroble Enligsh, ...

Search a collection for a sub type in C# / Linq

If I have a collection like List<SomeAbstractBaseType> someList = new List<SomeAbstractBaseType>(); And I have added two different child types to this collection (i.e. the two child types inherit from SomeAbstractBaseType) like this: someList.Add(someChildOfType1); someList.Add(someChildOfType2); someList.Add(someOtherChildOfType1);...

How do I use Like in Linq Query?

How I can use Like query in LINQ .... in sql for eg.. name like='apple'; thanks.. ...

Loop through controls and change LINQ columns

Hi I have the following code: Dim i As Integer For i = 1 To 20 Dim captionTextBox As TextBox = DirectCast(Me.FindControl("news_Image" + i.ToString() + "CaptionTextBox"), TextBox) Dim deleteCheckBox As CheckBox = DirectCast(Me.FindControl("Image" + i.ToString() + "DeleteCheckBox"), CheckBox) If Not deleteChec...

How can i enable Transaction my codes with linqto SQL?

if writing below codes: Error returns.i do like advise : http://stackoverflow.com/questions/794364/how-do-i-use-transactionscope-in-c But only error change:The partner transaction manager has disabled its support for remote/network transactions Exception from HRESULT: 0x8004D025 i am using windows server 2003. using (var stockMov...

Parent/Child tables not referencing in LINQ or am I just wrong?

I have a categories table "Category" [ID, Title] and a Parent/Child table "CategoryParent" [ID,CategoryID,ParentCategoryID] where a many-to-many tree is represented by the parent of a category being indicated using the ParentCategoryID field in the join table. I thought this would be a simple structure to use to retrieve root categories...

linq query gone bad

I have a really complicated linq query that I thought I finally got the syntax right for but it's throwing an exception at runtime: {"The method or operation is not implemented."} Could someone please take a look? Thanks! var order = from Ord in imageCreatorDataContext.Orders join Sub in imageCreatorDataCon...

What's the equivalent VB.NET syntax for anonymous types in a LINQ statement?

I'm trying to translate some C# LINQ code into VB.NET and am stuck on how to declare an anonymous type in VB.NET. .Select(ci => new { CartItem = ci, Discount = DiscountItems.FirstOrDefault(di => di.SKU == ci.SKU) }) How do you translate C#'s new { ... } syntax into VB.NET? ...

Filtering your LINQ to XML query

I have the following: XDocument xdoc = XDocument.Load("C:\\myfile.xml"); List<Tag> list = new List<Tag>(); foreach (var tag in xdoc.Descendants("META")) { string name = tag.Attribute("name").Value; string value = tag.Element("value").Value; list.Add(new Tag { Name = name, Value = value, Score = score, Key = key }); } but I need...

Nested multi-line lambda Function as parameter for LINQ Select is causing an error

I'm trying to use a nested multi-line lambda Function in VB.NET and am getting an error. Here's what my code looks like: cartItems = cartItems.Select(Function(ci) New With {.CartItem = ci, .Discount = discountItems.FirstOrDefault(Function(di) di.SKU = ci.SKU)}) .Select(Function(k) If k.Discount Is Not Nothing Then ...

Always exclude property from Entity Framework 4 Query

I have a user entity with the following properties that map to a field in the database: Id int Username varchar(25) Password binary(64) Salt binary(64) Name varchar(50) Locked bit What I don't want to do is always return the Password and Salt for every query. But for certain queries, I do want...

LINQ - querying top 5 with rank number

How do I return a top 5 with rank number using linq? Dim Top5 = From A In DAO.Cache.Select(Of VO.Empresa).Take(5) Select A.Nome I would like this result: Rank Name 1 "Example Name" 2 "Example Name" 3 "Example Name" 4 "Example Name" 5 "Example Name" ...

Captured variable in C# function with a List<> parameter

I have the following sample codes. I don't like to have lTest being captured and get the same value as lRet. I tried to introduce "List<Test> lTest1 = lTest0;" in the function AddMore2Test. It does not work. What is the proper way to do this? Thanks! Codes - private void Test(){ List<Test> lTest = GetInitTestList(); List<Test...

Fitnesse Slim query test fails while trying to access linq datacontext

I wrote a query that gets a list of objects using linq. The code executes fine in the project, but fails when I try to access it from the fitnesse project. base(global::System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString, mappingSource) I guess it has something to do with the connection strin...