Select new keyword combination
Hi, In LINQ, what does the select new keyword combination do? I haven't found much documentation on this. Thanks ...
Hi, In LINQ, what does the select new keyword combination do? I haven't found much documentation on this. Thanks ...
Hi, I have a sorted dictionary, which stores some data. Every two minutes or so I do the following: sorteddcitionary.Values.ToList() ----> This line throw exception sometimes. It is not consistent. The exception is as follows: System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Collections.Generic.S...
Hello, My app has quite a lot of entities with relationships. I have a scenario in which the entity should join all the contacts records (One to One). another scenario where I need only limited record without all the joins. For example, a "service call". This entity contains a number of one-to-one relationships: supplier, customer .. I ...
I have a rather complicated query that I'd like to have return some particular types. Mostly concerning date / time calculations or string values, the Entity Framework seems to be spitting the dummy when I try anything further than a System.DateTime type: The specified type member 'Date' is not supported in LINQ to Entities. Onl...
I want to split up a string, based on a predicate. As an example: "ImageSizeTest" should become "Image Size Test" Of course I could write a simple loop, going through the string, check for uppercased characters (the predicate) and build the new string. However I want this to be a bit more general, splitting up based on any predicate. S...
I'm trying to use the DbfDotNet library (http://dbfdotnet.codeplex.com) and replace my current ADO.NET methods of reading a very large dbf file (350.000+ records). I've tried the existing samples to read my file and file their custom Dataview and I'm very impressed with the speed. In my original code I fill a datatable with the content o...
I often want just the total count(or other aggregate) of a selection, typically when cruising through some data with LinqPad for example this query that returns the number of public enums in the core lib. "".GetType().Assembly.GetTypes().Where(t => t.IsPublic && t.IsEnum).Count() I know that I could do something like this: (from t in...
I've been working on an application that uses xVal's server side validation with data annotations. We recently ran into errors where the validation messages have been unpredictable for fields that have multiple validations that could fail if the field is empty (e.g., an email address is required, but also fails a validity check). Assum...
Hi folks, I have two linq (to EF4) queries, which return different results. The first query contains the correct results, but is not formatted/projected right. the second query is what i want but it missing some data. Schema Query 1 var xxxx = (from cp in _connectedClientRepository .GetConnectedClients(new[] { "LogEntr...
I have the following query: SELECT FROM tblMailToSend WHERE (DateToSend < @dateToSend OR DateToSend IS NULL) AND DateSent IS NULL @dateToSend is passed in as a param I'm trying to convert this to linq to sql query. I've got: db.MailToSend.Where(m => m.DateToSend == null || m.DateToSend <= dateToSend) .Where(m =>...
I'm frustrated... my site has suddenly become very unstable. So much so that hitting refresh over and over will cause it to crash. To investigate, I turned off all error handling so I could see some YSOD's. Instead of trying to write it all out, I made a video showing the issue. You can see it here on YouTube. Here's a copy of the stac...
I am experiencing a strange behavior using Nhibernate linq. I am querying for an entity based on a unique property in the class, although it is not technically the primary key. When I run the query with Nhibernate linq it returns the correct result, but the SQL generated has Select top 2 ... When I run the same query with icriteria there...
I am currently using VS2008, C# 3.5, and LINQ to read an XML file. (call it A.xml) I want to include other XML files in A.xml with xinclude. My initial attempts have failed, and I've not found any existing info published on how these two work together. I'm creating the root element of my query by calling XElement.Load() Is there some ot...
We are currently embarking on replacing the ADO.NET stack in our C# application with Linq. Because the application was not architected with a data abstraction layer, there are ADO calls throughout just about every layer of the application to such a degree that compartmentalizing any one object and trying to convert it to Linq means that...
Hi, I have a List<MyClass> and I want to sort it by DateTime CreateDate attribute of MyClass. Is that possible with LINQ ? Thanks ...
I tried to use linq to get storyboard data in code and try following where clause: Where( delegate (abc<VisualStateGroup, VisualState> xyz) { return (xyz.state.Name == "PopupOpened");} ) it gave me error: An anonymous method expression cannot be converted to an expression tree how to write the right where clause for t...
I'm trying to convert a Linq query to SQL. My Linq query looks like this: from s in Somethings where s.CreatedTime >= new DateTime(2010, 01, 01) where s.CreatedTime < new DateTime(2010, 02, 01) group s by s.Data into grouping select grouping.OrderByDescending(s => s.CreatedTime) .ThenByDescending( s => s.UpdatedTime) ...
In my LINQ to SQL generated classes I have some classes containing EntitySets. Everything looks great until I need to modify the EntitySet (add, delete some relationships). I thought that it was going to work doing something like: User.Actions = newUserActions; //This is how I used it with NHibernate Then when I try to submit chang...
Hi folks, I have an audit table and I'm trying to use Linq to figure out how to grab all the people's more recent audit actions. I'm just not sure how. Sample Schema Audit Table (technically it's actually a view) AuditId UserName Action CreatedOn 1 Bob Action1 2000-01-01 2 Bob Action2 2000-01-...
I have a CRUD repository as fallowing: public class CrudRepository<T> : ICrudRepository<T> where T : class, IUnique { static DataContext db = new DataContext(); protected DataContext DataContext { get { return db; } } public virtual IQueryable<T> GetAll() { return db.GetTable<T>(...