1
голосов
1ответов
305 просмотров

Missing namespaces, LINQ works in web app but not website!

Okay guys, I have an asp.net website set up to target the 3.5 framework, using Linq to Sql. However, the site won't build, and i get missing namespace and assembly exception whenever i try to. Here's the catch, I have installed 3.5 SP1, and I have added the System.Core, System.Data.Linq, System...

3
голосов
2ответов
537 просмотров

How can I reduce IEnumerable<ienumerable>&gt; to IEnumerable<foo>?</foo></ienumerable>

Sorry for the weird caption. What I'm trying to achieve is simple: IEnumerable&lt;IEnumerable&lt;Foo&gt;&gt; listoflist; IEnumerable&lt;Foo&gt; combined = listoflist.CombineStuff(); Example: {{0, 1}, {2, 3}} =&gt; {0, 1, 2, 3} I'm positive there is a Linq expression for this... Sidenote: T...

6
голосов
1ответов
4461 просмотров

Remove duplicates from DataTable and custom IEqualityComparer<datarow></datarow>

How have I to implement IEqualityComparer&lt;DataRow&gt; to remove duplicates rows from a DataTable with next structure: ID primary key, col_1, col_2, col_3, col_4 The default comparer doesn't work because each row has it's own, unique primary key. How to implement IEqualityComparer&lt;DataRo...

0
голосов
1ответов
1657 просмотров

Does StreamWriter work inconsistently with relative paths?

I am trying to save a LINQ XML document using a StreamWriter. Using the following code works fine when the document is small (~6kb on disk) but doesn't work when the file is larger (~66kb on disk). If I replace the relative path with an absolute path it works fine in both situations. Is there any...

0
голосов
1ответов
366 просмотров

Searching in xml with linq

I want to searching in a xml file. this is my linq sentece. string _sSemptom = "try"; XElement xe = from c in xdSemptom.Elements().Elements().Elements() .Elements().Attributes("Isim") where c.Value.Length &gt;= _sSemptom.Length &amp;&amp; ...

0
голосов
4ответов
847 просмотров

How do I filter an entity based on another entity? Linq many-to-many in C#

This is easy to do in SQL and I'm having a very hard time achieving this using Linq to SQL. I have two entities setup, Project and ProjectsbyUser: [Table(Name = "Projects")] public class Project { [Column(IsPrimaryKey = true, IsDbGenerated = true, Name="Job")] public string ProjectId {...

2
голосов
3ответов
2254 просмотров

ASP.NET MembershipUserCollection sort by IsApproved, Comment

Is it possible to sort a MembershipUserCollection by IsApproved and then Comment without modifying the Stored Procedure? Can Linq do this?

0
голосов
1ответов
1324 просмотров

Linq to Sql - Convert C# to VB.NET help

I'm having trouble converting a C# Linq statement to VB.NET. I need the following statement converted. I am getting hung up on the i.Sum(v=&gt;v) part. from p in Products from u in Users let i = (from op in OrderProducts where op.Order.User == u &amp;&amp; op.Product == p s...

2
голосов
2ответов
1522 просмотров

Why is Entity Framework ignoring the Take() method when generating SQL?

I am using the .Skip and .Take methods with Entity Framework. The .Skip call is being honored when generating the SQL. The .Take is not. This code: public IList&lt;DocPullRun&gt; GetDocRunsPaginated(int startRowIndex, int maximumRows) { Logger.Debug("GetDocRunsPaginated: star...

4
голосов
2ответов
2336 просмотров

NHibernate &amp; Linq - "could not resolve property"

Mapping-File: &lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DaVinci" namespace="DaVinci.Domain"&gt; &lt;class name="Waehrungskurs" table="WAEHRUNGSKURSE"&gt; &lt;id name="Id" column="ID"&gt; ...

11
голосов
7ответов
46682 просмотров

Why am I not getting .CopyToDataTable() in Linq Query()

This following code example is borrowed from MSDN here. I am not getting query.CopyToDataTable() available in my code. (see the commented line in my following code). public static bool SetPhysicianAsNotonServer(DataTable dt) { DataTable dtPhysicianServer = dt; ...

1
голосов
6ответов
5397 просмотров

How do you save a Linq object if you don't have its data context?

I have a Linq object, and I want to make changes to it and save it, like so: public void DoSomething(MyClass obj) { obj.MyProperty = "Changed!"; MyDataContext dc = new MyDataContext(); dc.GetTable&lt;MyClass&gt;().Attach(dc, true); // throws exception dc.SubmitChanges(); } The exceptio...

0
голосов
2ответов
1735 просмотров

using linq to select last written file

I wish to get the lastest written files from a directory and their extentions. An example of what file that could exist in the directory (with their creation dates): 2009-10-20T07:00:00.000 filename1.mp4 2009-10-20T07:00:01.000 filename1_0.mp4 2009-10-20T07:00:02.000 filename1_1.mp4 2009-10-20T...

4
голосов
5ответов
4570 просмотров

Pushing Items into stack with LINQ

How can i programatically push an array of strings into generic Stack ? string array string[] array=new string[]{"Liza","Ana","Sandra","Diya"}; Stack Setup public class stack&lt;T&gt; { private int index; List&lt;T&gt; list; public stack() { list = new List&lt;T...

0
голосов
5ответов
498 просмотров

stop sql insert in a for or while loop

i created a loop up to 100 to insert any data in db. but when i close my browser I hope it stops but it in background it continues looping and filling my db. how can I stop it? thanks

67
голосов
2ответов
48042 просмотров

F# List.map equivalent in C#?

Is there an equivalent to F#'s List.map function in C#? i.e. apply a function to each element in the list and return a new list containing the results. Something like: public static IEnumerable&lt;TResult&gt; Map&lt;TSource, TResult&gt;(this IEnumerable&lt;TSource&gt; source, Func&lt;TSourc...

1
голосов
2ответов
280 просмотров

Finding a specific XML element based on an ID using Linq

I want to find a section of xml based on a criteria so I’m using linq to XML. Unfortunately the result is always null so I guess I’ve done something wrong. Shown below is an example of the XML I’m parsing. &lt;Stuff&gt; &lt;ItemsA /&gt; &lt;ItemsB /&gt; &lt;ItemsC&gt; &lt;Item xmlns:i="http...

1
голосов
2ответов
98 просмотров

C#: XML To Type -LINQ

How to convert XML Elements to of type Person ? Elements : XElement persons = XElement.Parse( @"&lt;persons&gt; &lt;person&gt; &lt;id&gt;10001&lt;/id&gt; &lt;name&gt; Daniel &lt;/name&gt; &...

1
голосов
1ответов
558 просмотров

Parse string as DateTimeOffset in Expression<func bool>&gt;</func>

Hey, I am trying to create an Expression&lt;Func&lt;T, bool&gt;&gt; in which a string property is converted/cast to a DateTimeOffset so that DateTimeOffset operations can be performed on it. We are using Linq2SQL as our data provider, which does support converting strings to the SQL equivalent ...

2
голосов
1ответов
594 просмотров

Filtering one List<string> from another via LINQ</string>

I have a master list of colors: List&lt;string&gt; completeList = new List&lt;string&gt;{"red", "blue", "green", "purple"}; I'm passing in a List of existing colors of a product List&lt;string&gt; actualColors = new List&lt;string&gt;{"blue", "red", "green"}; How do I get a list back that i...

0
голосов
1ответов
5727 просмотров

Linq to sql multiple data context in same transaction

I am working on a project Where I have multiple reposetories to fetch data from differnt tables. All my repositories are independent, they create new dataContext, Add row to table and apply submit changes command. Now if in my service, there is a situation where I have to insert data into multip...

3
голосов
2ответов
8679 просмотров

Error with implicitly typed variables

When assigning a linq selection to an implicitly typed local variable "var" i receive the following error. Error :Cannot assign method group to an implicitly-typed local variable at root : var mailgroup = emails.Where(p =&gt;IsValidFormat(p.Value)).Select; Dictionary of elements Di...

0
голосов
1ответов
818 просмотров

How to implement a Query with IQueryable in SilverLight

I have two tables customers, pay and want to implement a gridview in silverlight with the outcome of the relationship of these two tables, the query is as follows SELECT Pa.Tipo_Pagare, Pa.Pagare, Pa.Rut, Cli.Nombre FROM Cred_Crexsa.dbo.Pagare AS Pa INNER JOIN Cred_...

1
голосов
2ответов
2348 просмотров

How to use isnull type decision in linqdatasource orderby?

I have a sql stored procedure that uses isnull in the order by clause to order items by the latest reply date, or if that is null, by the posting date: Example: ORDER BY isnull(rtb.LatestReplyDate,CB_TOPIC_DATE_POSTED) DESC I am trying to get that to work in the orderby clause of a linqdatasour...

326
голосов
5ответов
112099 просмотров

Flatten List in LINQ

I have a LINQ query which returns IEnumerable&lt;List&lt;int&gt;&gt; but i want to return only List&lt;int&gt; so i want to merge all my record in my IEnumerable&lt;List&lt;int&gt;&gt; to only one array. Example : IEnumerable&lt;List&lt;int&gt;&gt; iList = from number in (from no in Method(...

0
голосов
3ответов
437 просмотров

Dynamic LINQ with other databases

Are there any free (gratis) providers for databases other MS SQL (e.g. MySQL or SQLite) that work with LINQ and support dynamic SQL query generation? E.g. table.Count() generates something like SELECT COUNT(*) FROM table and doesn't first load the whole table and then count the rows.

2
голосов
1ответов
2392 просмотров

Reassign ItemsSource - Items collection must be empty before using ItemsSource

I'm using ItemsSource on a ListView. I now want to perform a search and filter the items with an SQL query, so I reassign the ItemsSource; but then an exception is thrown: Items collection must be empty before using ItemsSource. Alright, but how can I empty the items collection? Items.Clear is no...

0
голосов
1ответов
242 просмотров

How to use Entity context in entity class for performance?

Suppose I have project MyData, then I add MyDb.edmx with EF wizard. In My database, I have table Person. Then I will get an entity Person in EF model. Then I want to extend this Person by partial class in a separated file person.cs like: namespace MyData { public partial class Person ...

1
голосов
2ответов
658 просмотров

Linq XML Dynamic building

I am building an xml file. Parts of the file are static. Some of the file is dynamic. My code has an error of “Null object reference”. Any tips would be awesome. private XElement BuildDataElement() { // this is going to be more complicated return new XElement("data"); } pu...

3
голосов
3ответов
954 просмотров

Possible to group by Count in LINQ?

This might be either impossible or so obvious I keep passing over it. I have a list of objects(let's say ints for this example): List&lt;int&gt; list = new List&lt;int&gt;() { 1, 2, 3, 4, 5, 6 }; I'd like to be able to group by pairs with no regard to order or any other comparison, returning ...