How can i write this query with LINQ to a FoxPro database?
SELECT count(*) FROM Table group by item1
I wrote it as below, but it doesn't work
Dim Query
Dim dt As New DataTable
Dim da = New Odbc.OdbcDataAdapter("SELECT * FROM table1",connection)
da.Fill(dt)
Query = (From row In dt.AsEnumerable Select row_
Group By item1 ...
I am brand spanking new to LINQ and am trying to use it in my current hobby project. I have a datagridview where the first cell of each row is a datagridviewcheckbox, and the 4th cell is a string.
If the checkbox is checked, I need to add the 4th cell's value to a list.
At first I tried:
var selectedID = from c in multiContactLookup.S...
Working with interfaces, we commonly have a var or an IQueryable that is going to return a set of data objects that we will then cast to the interface and return as a List or IList, like this:
var items =
from t in SomeTable
where t.condition == true
select;
return items.ToList( ).Cast<SomeInterface>( ).ToList( );
NOTE:
items.Cast...
I guess it is something like sgen.exe which generates some serialization classes in separate assembly. Is that it? Should generated assembly be referenced? If so, by which project?
I have noticed that some LINQ queries are very slow, when executed for first time. Maybe bltgen tool can help?
I'll start a bltoolkit blog when I find all t...
Is it possible to select multiple entiies in ForEach Extension Method?
(i.e)
partial code is given
DataTableA.AsEnumerable().ToList().
ForEach(x=>
{
x.SetField<string>("Name","Jon Skeet"),
x.SetField<string>("msg","welcome")
});
when i apply multiple selection in ForEach
x=>
{
x.SetField<string>("Na...
For examples sake, lets say I have a table containing these columns
ID (primary key, auto increment)
FirstName (32 characters)
LastName (32 characters)
Picture (binary JPEG data containing on average 10k of data)
Using SubSonic and/or LINQ how can I update only the FirstName column of a record and not try to get the Picture column or...
I have a object User and it is the following class:
public class User
{
public int ID { get; set; }
public string Name { get; set; }
}
And I have a IEnumerable<User>
I want to find out if one specific user exists in IEnumerable<User>, comparing the user by it's ID.
An example:
IList<User> users = GetUsers(); // 1, 2, 3
...
I am trying to figure out how to create some dynamic queries. I have looked at Linq.Dyanmic and it is missing some things that I think I may need.
My goal is to essential flatten the relational database, this is for creating searches on the fly by the user, into one object with properties from many different tables/entities.
Example:
...
So, the context of this question is pretty specific, but I think there is a general C# question struggling to get out. :)
I have an ASP.NET Web Forms page with a GridView control bound to an ObjectDataSource. The data source control is hooked to a data access class that, in turn, uses LINQ to query Entity Framework v4. The methods on t...
I have functions that take SQL where clauses, and I'm wondering if there's a way to make them all strongly typed. Is there a way to take a lambda expression like a => a.AgencyID == id and convert it to a string where clause? Like "AgencyID = 'idValue'"?
Thanks!
...
Here's the sample XML
<?xml version="1.0" encoding="utf-8" ?>
<Instructions>
<Instruction>
<Brand>Brand1</Brand>
<Text>
this is text for Brand1
</Text>
</Instruction>
<Instruction>
<Brand>Brand2</Brand>
<Text>
Brand2 text is slightly different
</Text>
</Instruction>
<Instruction>
<Brand>...
If I have a text field that contains say a title and i have a list of keywords, how can i search the title checking for (n) numbers of keywords in the title?
So if my title is "Baking a chicken, bacon and leek pie" and the user searches for "chicken bacon turnip" i'd like to return the above recipe.
essentially i'd like to say that if ...
I've searched previous questions and can't seem to find what I'm looking for, so please excuse the n00b LINQ question... I'm working on becoming familiar with LINQ, and getting my head around the syntax and usage.
In my exercises, I put together the following query:
Dim r2 = From cust In cData.Customers _
Group Jo...
foreach (GridViewRow row in gridView.Rows)
{ // Access the CheckBox
CheckBox cb = (CheckBox)row.FindControl("SuburbSelector");
if (cb.Checked)
{
//do something;
}
}
I tried the following and got error
Linq:
var Str = SuburbGridView.Rows.Cast<GridViewRow>().Where(r=>(CheckBox)r.FindControl("SuburbSelector")==...
In a specific project at my work, I have a method that returns IList. But this interface does not contain where, or FindAll filters. However, when I open a new project, IList contains all. What is the difference?
...
I have a list of strings like
"00000101000000110110000010010011",
"11110001000000001000000010010011",
I need to remove the first 4 characters from each string
so the resulting list will be like
"0101000000110110000010010011",
"0001000000001000000010010011",
Is there any way to do this using LINQ?
...
this is data
id code status
1 1 5
2 1 6
3 2 8
4 2 9
5 2 12
6 3 15
7 3 19
8 3 13
what I need as a result is this:
id code status
2 1 6
5 2 ...
I have two strings
Like
"0101000000110110000010010011" and
"0101XXXXXXX101100000100100XX"
it should compare each character and it should not consider if the character is X
for the above two strings the result is true.
now i'm using like
Iterating through the length of the string and replacing thecorresponding character in firs...
I created a strongly-typed dataset in the dataset designer. The DataSet has a Table called FocusOffsetsTable and that table has four colums; SerialNumber, Filter, Wheel and Offset. I use the ReadXml() method of the DataSet class to load the strongly typed data from the xml file into the dataset. That seems to be working just fine.
I am ...
Consider the following rows in a database:
Id | Parent
__________________
1 null
2 1
3 2
4 3
5 null
6 5
Each Id that has a null Parent is the "Owner"/"Super Parent".
What would be the best approach, performance wise, to collect the parents and their children ? Shoul...