Friends, there is yet another scenario to solve. I am working it out without applying Linq.But I hope it is good opportunity for me to learn Linq if you share your code in Linq.
It is know as FLAMES
F - Friend
L - Lover
A - Admirer
M - Marry(Husband)
E - Enemy
S - Sister
Problem description:
Tw...
Hi,
I'm trying to accomplish the following query (notice .StartsWith):
return (from p in _session.Linq<Profile>()
where (p.Firstname + " " + p.Lastname).StartsWith(wildcard)
select p).ToList();
This throws: could not resolve property: Firstname.Lastname.
If I do this:
return (from p in _session.Linq<Profile>()
...
I am using Regular Expression for matching patterns say example in the follwoing example i am matching string to count vowels.
void VowelsCountInEachWord()
{
Regex rx = new Regex("[aeiou]");
var words=new string[]
{"aesthetic", "benevolent", "abstract",
"capricious", "complacent",...
I'm working on an app that generates reports that are basically standard SQL operations (sum/average on data grouped by A/B where X=Y etc)
the parts of the query can be defined by the user at runtime. as implemented, the raw data is in a a DataTable and I "parse" the query parameters into a linq expression (basically query operands map ...
I'm creating an options dialog using WPF that lists possible keys so that the user can assign the program's hotkey. I'm attempting to filter all of the possible values of the System.Windows.Forms.Keys enumeration down to just A-Z and F1-F12, and then bind that list to a ComboBox.
Here's my code so far:
Regex filter = new Regex("(^[A-...
From the given set
{1,2,3,4,5,6,7,8,99,89}
What is the way to get all possible two numbers subset using LINQ?
(i.e) {1,2},{1,3},{1,4} .....
...
when i form the following code
Rabbit[] rbt=
new Rabbit[]
{
new Rabbit{ Name="Jobby", Vegetable=new Vegetable{ VegiName="carrot"}},
new Rabbit{ Name="hobby", Vegetable=new Vegetable{ VegiName="Beetroot"}}
};
var s = from bt in rbt where
bt.Vegetable.VegiName.CompareTo("carrot") == 0 select bt;
foreach (var v in s)
{
...
I have used LINQ-to-SQL in WPF and ASP.NET MVC projects in the following way:
create database
drag tables into the designer
use generated classes with LINQ
Now I have a project where the data sources are a mix of web services, a database, and XML files. From what I understand of Entity Framework, I can create similar classes as I can...
When an attempt to solve the problem
How many seven-element subsets (not repeatable) are there
in a set of nine elements ?
I tried
IEnumerable<string> NineSet =new string[] {"a","b","c","d","e","f","g","h","i"};
var SevenSet =
from first in NineSet
from second in NineSet
where first.CompareTo(second)< 0 && first.Count()...
i fail while converting this sql to linq...
hope anybody do it.
SELECT Max([PersonalNumber]+1)
FROM TestTable
GROUP BY CalYear
HAVING CalYear=Year(Now())
Thanks.
...
From the given setup
IEnumerable<int> one = new int[] { 1, 2, 3, 4, 5, 6, 7 };
IEnumerable<int> two = new int[] { 12, 34, 56, 7, 8 };
MySet[] sets
= new MySet[]
{
new MySet{ MySetID =100, MySubSet=new MySubSet{SubSet=new List<int>(one),
SubSetID=1212}},
new MySet{ MySetID =101, MySubSet=new MySubSet{SubSet=new List<int>(t...
Hi there, wondering if anyone can help. This works, but I was wondering how it would look in Lambda instead (Just curious !)
Codes is simply an array of id's and each item has a code...
var qry = from i in items
where Codes.Contains(i.Code)
select i;
return qry.ToList();
Thanks
Andrew...
suppose i have xml similar to the below
<?xml version=”1.0” encoding=”UTF-8”?>
<validate status=”yes” last_updated=”2009-07-05T11:31:12”>
etc...etc
</validate>
in c# how can i get the value of status in the validate element?
there will only be one validate element.
how can i do this with linq?...or if theres a simpler way maybe
...
I've got a repository using LINQ for modelling the data that has a whole bunch of functions for getting data out. A very common way of getting data out is for things such as drop down lists. These drop down lists can vary. If we're creating something we usually have a drop down list with all entries of a certain type, which means I ne...
This might be either impossible or so obvious I keep passing over it.
I have a list of objects(let's say ints for this example):
List<int> list = new List<int>() { 1, 2, 3, 4, 5, 6 };
I'd like to be able to group by pairs with no regard to order or any other comparison, returning a new IGrouping object.
ie,
list.GroupBy(i => someLo...
I am building an xml file. Parts of the file are static. Some of the file is dynamic. My code has an error of “Null object reference”.
Any tips would be awesome.
private XElement BuildDataElement()
{
// this is going to be more complicated
return new XElement("data");
}
public void TestXML(string fname)
{
// b...
Suppose I have project MyData, then I add MyDb.edmx with EF wizard. In My database, I have table Person. Then I will get an entity Person in EF model.
Then I want to extend this Person by partial class in a separated file person.cs like:
namespace MyData
{
public partial class Person
{
[DataMember]
public int ...
I'm using ItemsSource on a ListView. I now want to perform a search and filter the items with an SQL query, so I reassign the ItemsSource; but then an exception is thrown:
Items collection must be empty before using ItemsSource.
Alright, but how can I empty the items collection? Items.Clear is not allowed when using ItemsSource..
Okay, ...
Are there any free (gratis) providers for databases other MS SQL (e.g. MySQL or SQLite) that work with LINQ and support dynamic SQL query generation? E.g. table.Count() generates something like SELECT COUNT(*) FROM table and doesn't first load the whole table and then count the rows.
...
I got a linq query who returns a IEnumarable<List<int>> but i need to return, only List<int> so i want to merge all my record in my IEnumerable<List<int>> to only one array.
Example :
IEnumerable<List<int>> iList = from number in (from no in Method() select no) select number;
I want to take all my result IEnumerable<List<int>> to onl...