from f in CUSTOMERS
where depts.Contains(f.DEPT_ID)
select f.NAME
depts is a list (IEnumerable<int>) of department ids
this query works fine until you pass a large list (say around 3000 dept ids) .. then i get this error:
The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Too many parameter...
How do i dispose reference to the subWeb in the following query?
using (SPSite spSite = Utility.GetElevatedSite(_rootUrl))
{
from SPWeb web in spSite.AllWebs
where web.ServerRelativeUrl.ToLower() == path
from SPWeb subWeb in web.Webs
select subWeb
}
Do i even need to worry about disposing th...
So the nHibernate 2.1 Alpha came out a few days ago, but the announcement on sourceforge doesn't mention the additional features. In particular, it doesn't mention whether LINQ is included. I know that I've read that LINQ would be part of 2.1, but that was 6 months ago. Anybody know if LINQ is in 2.1 or what new features are? There's no ...
When constructing LINQ expressions (for me, linq to objects) there are many ways to accomplish something, some much, much better and more efficient than others.
Is there a good way to "tune" or optimize these expressions?
What fundamental metrics do folks employ and how do you gather them?
Is there a way to get at "total iterations...
I'm going through an XML file of articles and the journalist(s) that wrote them. As we are adding the articles into _Data our datacontext we may come across a journalist that needs adding so we do this:
newJourno = New journalist With {.name = strJournalist}
_Data.journalists.InsertOnSubmit(newJourno)
.articles_journalists.Add(New artic...
I have the following code:
var tagToPosts = (from t2p in dataContext.TagToPosts
join t in dataContext.Tags on t2p.TagId equals t.Id
select new { t2p.Id, t.Name });
//IQueryable tag2postsToDelete;
foreach (Tag tag in tags)
{
Debug.WriteLine(tag);
tagToPosts ...
I am trying to force a ChangeConflictException by altering records in two different browsers. This has worked for me in the past. But now it just wont throw the exception.
Last one in is winning.
I have checked the column properties of the entity I am updating and each column is set to always check.
Is there anything I can look for?
...
I have an XML document defined like so
XML File
<TABLE>
<RECORD>
<PAGENUMBER> 1 Of 1</PAGENUMBER>
<OtherFields1>..</OtherFields1>
<OtherFields2>..</OtherFields2>
</RECORD>
<RECORD>
<PAGENUMBER> 1 Of 2</PAGENUMBER>
<OtherFields1>..</OtherFields1>
<OtherFields2>..</OtherFields2>
</RECORD>
...
What is the best way to check for concurrency issues when using LINQ to SQL in an ASP.net application.
In my application, I am retrieving a record from the database and displaying the fields in editable textboxes. Then the datacontext is thrown away.
How should I save the entity object so that I can use L2Sql's built in concurrency fea...
Here's my reqiurements:
Supports C#
Supports Oracle
Supports LINQ
Has ability to map business objects to database tables (not necessarily a 1-to-1 mapping)
I know an Oracle Entity Framework provider would support all these, but I've been told that making the custom mappings is not very easy.
What would you suggest?
...
Does LINQ and Lambda expressions reduce cyclomatic-complexity? Just curious because CodeRush actually shows a reduction in cc when the VS analyzer increases it.
...
I have a varbinary(max) field in one of my tables but I don't need it every time and I'm looking for a way to fetch it from the database only when necessary. I'm using ADO.NET Entity Framework. How to do that?
...
I'm trying to query an Entity to return multiple rows based on a filter.
For instance in SQL we have:
SELECT * FROM table WHERE field IN (1, 2, 3)
How do I do it in LINQ to Entities?
...
Good Day,
I have C# code to populate a dropdown list in Silverlight which works fine except when there are duplicates. I think because IEnumerable is a collection, it filters out duplicates. How would I code my LINQ query to accept duplicates?
My Sample Data looks like:
Code => CodeName
FGI Field General Initiative
SRI Sta...
I would like to normalize data in a DataTable insertRows without a key. To do that I need to identify and mark duplicate records by finding their ID (import_id). Afterwards I will select only the distinct ones. The approach I am thinking of is to compare each row against all rows in that DataTable insertRows
The columns in the DataTa...
Could any of you please show me how to complete the following tasks?
// Prepare object to be saved
// Note that MasterTable has MasterTableId as a Primary Key and it is an indentity column
MasterTable masterTable = new MasterTable();
masterTable.Column1 = "Column 1 Value";
masterTable.Column2 = 111;
// Instantiate DataContext
DataCont...
Hi,
I wrote the following code to extract out the exceptions along with a string key referencing the property from the ViewData.Modelstate property in ASP.Net MVC. I think it should be possible to do this with a Linq expression but it utterly flummoxed me.
var exceptions = new Dictionary<string, Exception>();
foreach (KeyV...
I've just replaced this piece of code:
foreach( var source in m_sources )
{
if( !source.IsExhausted )
{
....
}
}
with this one:
foreach( var source in m_sources.Where( src => !src.IsExhausted ) )
{
...
}
Now the code looks better (to me) but I'm wondering what's really happening here. I'm concerned about perf...
When writing a LINQ query with multiple "and" conditions, should I write a single where clause containing && or multiple where clauses, one for each conditon?
static void Main(string[] args)
{
var ints = new List<int>(Enumerable.Range(-10, 20));
var positiveEvensA = from i in ints
where (i > 0) && ((i %...
I'm trying to create an expression to be used by the Where method of a LINQ to Entities query.
Effectively:
query.Where(farm => farm.PartyId == id);
(id is an int)
The code I'm using is:
private struct Parameter<T>
{
public T Value;
public Parameter(T value)
{
Value = value;
}
}
Parameter<int> idParameter...