linq

Disconnected DataSet

Hi, I am looking for architecture like as follows: Database --> DataSet --> DataContext(Linq)/ ORM Entity --> GUI Application I want to fetch data from database and keep into DataSet so if database id disconnect my application doesn't affect. But DataSet is not supporting Object-Relational-Mapping (ORM) Model. I am interested in ...

Can't access Element after DataContractSerializer

I have a simple object I'm trying to serialize using DataContractSerializer. In my unit test, I'm trying to verify the xml contains the right value for the product/sku node. My product class: [DataContract(Namespace = "http://foo.com/catalogue/") partial class Product { [DataMember(Name = "sku")] public virtual string ProductSKU...

Fetch from foreign key tables with LINQ and LINQ to SQL

Hi I have an database table called MenuItem (MenuItemID, ParentMenuItemID, MenuItemName). I want to use this to populate a Menu control (probably the .NET Menu control). Each MenuItem has a parent. If there is no parent, it is a top level menu item. I have made a LINQ to SQL class mapped to the MenuItem table. As my table has a foreign...

How to retrieve multiple rows from a stored procedure with Linq to SQL?

I've recently started to work with Linq to SQL and wondered how to get multiple rows as a result of executing a stored procedure,here's a simple sp i want to work with: CREATE PROCEDURE gsp_ftsmultiple @SearchKey varchar(100) AS BEGIN SET NOCOUNT ON; SELECT Label, theContent FROM FtsTest WHERE FREETEXT( theContent, @Se...

Is an IQueryable a query or just an object which can be queried?

I'm kinda confused what the IQueryable interface actually represents. The MSDN documentation for IQueryable says: "Provides functionality to evaluate queries against a specific data source." The documentation for IQueryProvider says: "Defines methods to create and execute queries that are described by an IQueryable object." The name a...

Disconnected DataSet

DataContext/Entity Model always read data from Database. is there any way DataContext/Entity Model will read the data from DataSet. Thanks ...

How to perform an update using Linq or Lambda?(C#, Asp.net,Linq , Lambda)

How can I do an update in Linq My code is List<Cart> objNewCartItems = (List<Cart>)Session["CartItems"]; if ((objNewCartItems != null) && (objNewCartItems.Count > 0)) { for (int i = 0; i < dgShoppingCart.Rows.Count; i++) { Cart c = new Cart(); ...

Linq Compiled Queries and int[] as parameter

Hello , i'm using the following Linq to Sql compiled query. private static Func<MyDataContext, int[], int> MainSearchQuery = CompiledQuery.Compile((MyDataContext db, int[] online ) => (from u in db.Users where online.Contains(u.username) select u)); I know it is not possible to use sequence input pa...

C# Linq Result ToDictionary Help

I have a lambda expression that gets results from a Dictionary. var sortedDict = (from entry in dctMetrics orderby entry.Value descending select entry); The expression pulls back the pairs I need, I can see them in the IDE's debug mode. How do I convert this back a dictionary of the same type as ...

Please help me convert a Linq Query to a SQL Query... Desperate...

Hey all, Im pretty proficient in LINQ, but not in SQL. I understand cursors are horrible and shouldn't be used. I know SQL Syntax pretty well, but I am trying to figure out how to convert this query and update to SQL from Linq. I don't know how to go through the Foreach of SQL without using cursors and Im a bit lost on what to do ne...

Linq to SQL & Logical partitioning (DAL, BLL)

We're going to be rebuilding one of our sites in .Net. I've read many articles and really like the idea of separating our project into a data access layer (DAL), Business logic layer (BLL), and presentation layer (we're coming from classic ASP so this is a massive step for us). I also really like Linq to SQL. Since Linq to SQL is aimed...

Linq - OrberBy the minimum value of two colums

I have an entity set that contains two DateTime properties. I want to order the set by the minimum value of the two properties. How can I do this with a lambda expression. ...

Is it worth using PLINQ with ASP.NET?

Does anyone have experience using PLINQ with ASP.NET? Is this a good combination, or something to avoid in most situations? I develop an intranet ASP.NET site for a lawfirm (~100 users). Several pages include non-trivial LINQ code, for example, we have a bank rec page that compares thousands of financial transactions between our accou...

is it possible to use linq on "sql server project"

I'm using visual studio 2008. How can i use linqtosql on the sql server project? ...

Fill a Recursive Data Structure from a Self-Referential Database Table

This question refers to http://www.matthidinger.com/archive/2009/02/08/asp.net-mvc-recursive-treeview-helper.aspx Let's say I have a table that looks like this: And I have a recursive data structure that looks like this: public class TreeNode { public TreeNode(){} public string NodeId { get; set; } public string ParentId...

Can the where-condition in this LINQ-query be optimized?

Hey! I have this LINQ-query: bool? a, b, c; from i in _ctx.SomeEntitySet where (a == null ? true : i.IsA == a) && (b == null ? true : i.IsB == b) && (c == null ? true : i.IsC == c) select i; I only want to take the condition IsX == x in...

How to sort an List collection of classes with properties in them?

Hi I have a List of classes in my collection like List<MyClass> test = new List<MyClass>(); In my classes I have just some properties public string id {get; set;} public DateTime date {get; set;} Now I make these classes by getting some queries from 2 different database tables. I then take those 2 results from the database tables ...

can I use Linq to Xml to alter an XSD?

I've got a node in an XSD that I'd like to modify. I'd like to change the "name" value in this node: <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> However when I try to find that node via this code, I get either no nodes or an error, depending on what I try. xsdDoc.Descendants("element").Where...

Optimize Code by using yield or changing algorithm

The code below works but I want to optimize the code using yield or by changing algorithm. public IEnumerable<Book> GetAuthorWithBookName(string keyword) { var bookAndAuthorList = new List<Book>(); List<Author> AuthorNameList = getAuthorName(keyword); foreach (var author in AuthorNameList) { XmlNode booksNames = ...

Using a single GridView and a LinqDataSource, how would you update data from a parent table and a child table?

I'm using a GridView and a LinqDataSource to display data from an entity called CHILD in this example. CHILD has an association with the PARENT entity. I'm having no problems displaying data from both these entities in a single GridView since related PARENT records are exposed as a property in CHILD. However, I can't figure out a wa...