Hi Guys,
Trying my hand at ADO.Net data services. All the examples shows how to retrieve lists but how would you go about retrieving a single value? e.g. Product X's Price.
Here is the LINQ query i use:
var qry = (from p in
svcContext.Products
where p.ProductName == "Chair"
&& p.Co...
Hi i've got 2 data tables (bannedlist,countrylist), both contains list of country names and cods in columns cc and country. I am trying to do a query where i can select countries from countrylist table that are not in bannedlist table in order to create a 3rd table.
Any ideas?
I haven't got too far with this.
var ccList = ds.T...
I'm stumped by this easy data problem.
I'm using the Entity framework and have a database of products. My results page returns a paginated list of these products. Right now my results are ordered by the number of sales of each product, so my code looks like this:
return Products.OrderByDescending(u => u.Sales.Count());
This returns...
how can i call the delete store procedure in linq query
...
public class TestClass
{
public TestClass(int id, string name)
{
Name = name;
Id = id;
}
public string Name
{ get; private set; }
public int Id
{ get; private set; }
public string Tag
{ get; set; }
public DateTime Time
{ get; set; }
}
private static void Main(string[] args)...
Hi,
I've been developing a webapp using Linq to NHibernate for the past few months, but haven't profiled the SQL it generates until now. Using NH Profiler, it now seems that the following chunk of code hits the DB more than 3,000 times when the Linq expression is executed.
var activeCaseList = from c in UserRepository.GetCases...
Why does this work ?
var x = from p in db.People let oCount = p.Orders.Count select p;
And not this ?
var x = from p in db.People let oCount = Count(p) select p;
private int Count(DataContext.Order o)
{
return o.Count;
}
...
I always assumed that if I was using Select(x=> ...) in the context of LINQ to objects, then the new collection would be immediately created and remain static. I'm not quite sure WHY I assumed this, and its a very bad assumption but I did. I often use .ToList() elsewhere, but often not in this case.
This code demonstrates that even a si...
How can I implement the so called "repository pattern" that Rob Conery shows in [MVC Storefront][1] when I use two different generated linq codes? Do I need to implement a real repository pattern as Fredrik Normen discusses at What purpose does the Repository Pattern have?? The thing is that I want pass some of the nice features that LIN...
List<int> a = new List<int>{ 1,1,2,2,3,4,5 };
What's the quickest way to do this with LINQ?
I'm new to LINQ
...
So we have an XML file with a very simple implementation of XLink:
<root xmlns:xlink="http://www.w3.org/1999/xlink">
<firstChild id="ID1" />
...
<ref xlink:href="#ID1" />
</root>
Let's assume the XLink implementation won't get any more complicated than that. However the important point is that the element referred to (in this...
I think its easy LINQ question, but i am very new to LINQ
I have this array:
int[] array = new int[7] { 1, 3, 5, 2, 8, 6, 4 };
and i wrote this code to get top 3 elements in this array:
var topThree = (from i in array orderby i descending select i).Take(3);
and when i check whats inside the topThree i find:
{System.Linq.Enumerabl...
Hi,
Lets look at the following structure first (I have tried to simplify it to just show what kind of query I want)
class NameAddress
{
public string Name { get; set; }
public string Address { get; set; }
public NameAddress(string sName, string sAddress) { Name = sName; Address = sAddress; }
}
static voi...
Hi,
I'm trying to extend my webapp with IronPython, which is working wonderfully so far, but I can't seem to get it to play nicely with my NHibernateLinq setup.
I'm making an IQueryable<Case> available to the IronPython code, and then I'm using the Linq methods to filter it down, such as:
Enumerable.Where[object](data, Func[object, bo...
I have just started a new project using a Linq to Sql model and I'm implementing our first many to many relationship. I have found this blog that gives great info on how implement this:
http://blogs.msdn.com/mitsu/archive/2008/03/19/how-to-implement-a-many-to-many-relationship-using-linq-to-sql-part-ii-add-remove-support.aspx
When I t...
I have a number of tables in SQL. One is Controls (a typical CRUD sort of object) and one is Attachments. Attachments references Controls via a FK (there can be many attachments). Attachments also includes, amongst other things, a name and a varbinary column with file data.
Through linq, Control has an Attachments property.
I have a Co...
When I insert data with the following code, I see the exception. What should I do?
Code:
Movie_List_DBDataContext Movie_list1 = new Movie_List_DBDataContext();
Actor act = new Actor();
act.Actor_Name = Acttxt.Text;
Movie_list1.Actors.InsertOnSubmit(act);
Movie_list1.SubmitChanges();
Exception:
Violation of PRIMARY KEY constrain...
I want to get the total number of items in the Lists in the following Dictionary:
Dictionary<int, List<string>> dd = new Dictionary<int, List<string>>() {
{1, new List<string> {"cem"}},
{2, new List<string> {"cem", "canan"}},
{3, new List<string> {"canan", "cenk", "cem"}}
};
// This only returns an enumerated array.
var i =...
Hi,
I have a dynamic SQL string which I want to evaluate and return as a LINQ-object.
Is there any easy way to do this in C#? Have tried googleing it, but haven't found anything.. So all(or most) answers are appreciated.
Best Regards,
Robin
...
Thanks to this question I managed to work out how to constrain my generic method to accept only enums.
Now I'm trying to create a generic method so that I can bind a drop-down to any enum I choose, displaying the description in the drop-down, with the value equal to the numeric value of the enum value.
public static object EnumToDataSo...