I'm using LinqToSql to query a small, simple SQL Server CE database.
I've noticed that any operations involving sub-properties are disappointingly slow.
For example, if I have a Customer table that is referenced by an Order table, LinqToSql will automatically create an EntitySet<Order> property. This is a nice convenience, allowing me ...
Say I have the following LINQ queries:
var source = from workflow in sourceWorkflowList
select new { SubID = workflow.SubID,
ReadTime = workflow.ReadTime,
ProcessID = workflow.ProcessID,
LineID = workflow.LineID };
var target = from workflow in t...
I need to test a logical expression held in a string to see if it evaluate to TRUE or FALSE.(the strig is built dynamically)
For example the resulting string may contain "'dog'<'cat' OR (1>4 AND 4<6)". There are no variables in the string, it will logically evaluate. It will only contain simple operators = > < >< >= <= and AND , OR and O...
Hi,
I have added 1000 records into DataTable using C#.Net. This data table contains TimeStamp column for specified data stored time. Data stored into 5/21/2010 1:34:02 PM to 5/21/2010 2:34:02 PM every 10 seconds once. Here i want to fetch only 5/21/2010 1:44:02 PM to 5/21/2010 1:54:02 PM records using Linq-to-Datasets Query. I don't kno...
I'm trying to make a query that grabs a single row from an SQL database and updates it.
TableA
AId
AValue
TableB
BId
AId
BValue
Ok, so TableA and TableB are linked by AId. I want to select a row in TableB based on AValue using a join. The following query is what I have and only grabs a value from TableB based on AId, I just don't...
Hi, I want to Enumerate Linq Query. Below i specified example.
EX:
DataTable _slidingDataTable = new DataTable("test");
for(int i=0; i<5;i++)
{
DataRow row = _slidingDataTable.NewRow();
startPosition = DateTime.Now;
for(int i=0; i<5;i++)
{
_slidingDataTable.Columns.Add("TransferTime");
row[columnName] = sta...
Is this:
Box boxToFind = AllBoxes.Where(box => box.BoxNumber == boxToMatchTo.BagNumber);
EDIT:
Box boxToFind = AllBoxes.FirstOrDefault(box => box.BoxNumber == boxToMatchTo.BagNumber);
Faster or slower than this:
Box boxToFind ;
foreach (Box box in AllBoxes)
{
if (box.BoxNumber == boxToMatchTo.BoxNumber)
{
boxToF...
I have questions that may or may not have a question_group
if all the questions do not have a question_group and if I use default if empty like this:
question_group defaultQuestion = new question_group {question_group_id = Guid.Empty};
questions.Select(x => x.question_group).DefaultIfEmpty(defaultQuestion).Distinct();
shouldn't I get...
I currently have a log object I'd like to remove objects from, based on a LINQ query. I would like to remove all records in the log if the sum of the versions within a program are greater than 60. Currently I'm pretty confident that this'll work, but it seems kludgy:
for (int index = 0; index < 4; index++)
{
Lo...
I have a link sequence, and I want to order by User.Name (its a sequence of users).
How can I do that?
Also, if I want to remove any users with User.Count = 0 can I do that in the same query?
...
Imagine you have int[] data = new int [] { 1, 2, 1, 1, 3, 2 }
I need sub-array with only those which conform to a condition data[i] > data[i-1] && data[i] > data[i + 1]... i.e. I need all items which stick over their immediate neighbours.
From example above I should get { 2, 3 }
Can it be done in LINQ?
Thanks
...
I have the following code to retrieve customer name, total (orders ), sum (order details) for reach customer in Northwind database. The problem with below code is that it raises an exception since a few customers dont have any entry in orders table.
I know using the query syntax (join) the exception can be avoided. I want to know if th...
I have a LINQ query that searches for multiple keywords on multiple columns. The intention is that the user can search for multiple keywords and it will search for the keywords on every property in my Media entity. Here is a simplified example:
var result = repository.GetAll<Media>().Where(x =>
x.Title.Contains("Apples") || x.Descri...
For one of my clients I'm currently building an application that communicates with a legacy Microsoft Access database. Migrating to SQL server is unfortunately not (yet) an option. I currently write the queries using OleDbConnection, OleDbCommand and –good old- text based queries. As you can imagine I'm a bit spoiled by using modern O/RM...
i am trying to do
using (UserManagementDataContext context = new UserManagementDataContext())
{
var users = from u in context.Users
where u.UserEMailAdresses.EMailAddress == "[email protected]"
select u;
return users.Count();
...
In our web application we have a lots of stored procedures look like this one:
getSomeData(/* 7 diffrent params */)
This stored procedure don't make any updates. We are using Linq'u.
I know that the date are changing no often than once per day
so the results for the same sets of parameters values will be the same.
Does Linqu have ...
this linq query
var users = from u in context.Users
where u.UserEMailAdresses.Any(e1 => e1.EMailAddress == userEMail) && u.UserPasswords.Any(e2 => e2.PasswordSaltedHash == passwordSaltedHash)
select u;
return users.Count();
returns: 1 even when there is nothing in password table.
how come?
what i am trying to...
Do you see a better approach to obtain and concatenate item.Number in a single string?
Current:
var numbers = new StringBuilder( );
// group is the result of a previous group by
var basenumbers = group.Select( item => item.Number );
basenumbers.Aggregate
(
numbers,
( res, element ) => res.AppendFormat( "{0:00}", element )
);
...
My practice shows that a general enterprise application has a lot of entities which's nature corresponds to an elementary enumeration. For example We may have an Order entity which may have such fields as "OrderType", "OrderStatus", "Currency", etc. referencing corresponding Entities which are nothing more than just a textual name bound ...
I want to bind Repeater control to Dataset which is filled with XML data, but i don't know how to show attributes inside repeater.
Xml File:
<root>
<items>
<item id="9" name="111111111111" description="111111245" views="1" galleryID="0" />
</items>
</root>
Repeater code:
<asp:Repeater ID="rptrGalleries" runat="server">
...