Orderby() not ordering numbers correctly c#
Int32.Parse is not supported by the LinqToSql translator. Convert.ToInt32 is supported. http://msdn.microsoft.com/en-us/library/sf1aw27b.aspx http://msdn.microsoft.com/en-us/library/bb882655.aspx
Int32.Parse is not supported by the LinqToSql translator. Convert.ToInt32 is supported. http://msdn.microsoft.com/en-us/library/sf1aw27b.aspx http://msdn.microsoft.com/en-us/library/bb882655.aspx
I think I have the answer here, which is not as elegant as I’d hoped, but it should do the trick: var studentIDs = StudentClasses.Select(sc => sc.StudentID) .Union(StudentTeachers.Select(st => st.StudentID); //.Distinct(); — Distinct not necessary after Union var q = from id in studentIDs join sc in StudentClasses on id equals sc.StudentID into jsc from … Read more
Entities can be created outside of queries and inserted into the data store using a DataContext. You can then retrieve them using queries. However, you can’t create entities as part of a query.
The limits are hard-coded: Parameters per stored procedure 2,100 Parameters per user-defined function 2,100 I wrote some code before that split the Contains query into batches and combined the results… see here for more.
It depends on what behavior you want. Returning an IList<T> tells the caller that they’ve received all of the data they’ve requested Returning an IEnumerable<T> tells the caller that they’ll need to iterate over the result and it might be lazily loaded. Returning an IQueryable<T> tells the caller that the result is backed by a … Read more
If Ids is a List, array or similar, L2S will translate into a contains. If Ids is a IQueryable, just turn it into a list before using it in the query. E.g.: List<int> listOfIDs = IDs.ToList(); var query = from st in dc.SomeTable where listOfIDs.Contains(st.ID) select …..
Interestingly, this has been identified for several versions now (you stated that a 3.5 issue was fixed in 4.0). Here is a post from 2007. The rest of the IList methods in 4.0 are correctly tied to the IList<T> methods. I think that there are 2 likely explanations (of the bug/feature variety): This is an … Read more
If you’re absolutely sure your numbers will always stay within the range of smallmoney, use that and you can save a few bytes. Otherwise, I would use money. But remember, storage is cheap these days. The extra 4 bytes over 100 million records is still less than half a GB. As @marc_s points out, however, … Read more
If you express it as a where clause it may just work out of the box with LINQ to SQL, if you can construct an appropriate expression. There may be a better way of doing this in terms of the expression trees – Marc Gravell may well be able to improve it – but it’s … Read more
This is what I found seems like you still have to do a group by…can just use constant: var orderTotals = from ord in dc.Orders group ord by 1 into og select new { prop1 = og.Sum(item=> item.Col1), prop2 = og.Sum(item => item.Col2), prop3 = og.Count(item => item.Col3) }; This produces the following SQL, which … Read more