Zuker On Foundations

The realm of .NET (WPF, WCF and all around)

Browse by Tags

All Tags » LINQ (RSS)
LINQ to SQL – IsNull and Ordering
I thought I would share a nice small tweak I made to a LINQ to SQL model. Assume I have the following table structure for ‘Categories’: I faced with the need to select categories while ordering it by the combination of Description1 and Description2 (Note: nullable fields). I entered some dummy data to the table to illustrate the point: The goal is to retrieve the order as follows: 1, 3, 5, 2, 4 After explaining that, lets forward to the LINQ statements then. Take 1 – Simple Aggregation var query...

Posted Saturday, January 30, 2010 12:00 AM by Amir Zuker | 2 comment(s)

תגים:, ,

LINQ to XML - XElement - Descendants vs. Elements
Someone asked me what the difference between descendants and elements is, I thought I'd post the details here for common interest. Descendants will yield you elements of your choice from the entire source element sub-tree, whereas Elements will yield the child elements only. E.g. string xml = @" <Root> <Item> <id>1</id> </Item> <Item> <id>2</id> </Item> <Item> <id>3</id> <Items> <Item> <id>5</id>...

Posted Thursday, January 15, 2009 3:25 PM by Amir Zuker | with no comments

תגים:,

LINQ to SQL Dynamic Mapping
Via this post . The post discusses the issue of using LINQ-to-SQL with dynamic mappings. The problem You have SQL Servers for each of your environments (development, test, pre-prod, production) and in each one, the table names are different. In fact, it’s not the table names that are different but the schema names but since the schema name is part of the table name, it must be specified. Ex : dev.ZeTable et prod.ZeTable Easy to solve, right? Just put the schema value in the config file and do a simple...

Posted Thursday, January 15, 2009 3:25 PM by Amir Zuker | with no comments

תגים:,

LINQ To Regex
Via this post by Roy Osherove. A nice approach for working against regular expressions. I must admit, it looks as if it would take some time to master and love. Nice to know it's out there :) [ Test ] public void FindEmailUsingPattern () { var query = from match in RegexQuery . Against ( "sdlfjsfl43r3490r98*(*Email@somewhere.com_dakj3j" ) where match . Word . Repeat . AtLeast ( 1 ) . Literal ( "@" ) . Word . Repeat . AtLeast ( 1 ) . Literal ( "." ) . Choice . Either...

Posted Thursday, January 15, 2009 3:24 PM by Amir Zuker | with no comments

תגים:,

Batch Updated and Deletes with LINQ to SQL
A great post by Terry Aney . The post explains the gotchas when using LINQ to SQL to perform batch updates and deletes and offers an elegant and a very impressive solution! Worth checking it out.

Posted Thursday, January 15, 2009 3:24 PM by Amir Zuker | with no comments

תגים:,

LINQ to XSD Alpha 0.2
A new version of LINQ to XSD had been released last week. The new version works with the final release of VS 2008. "The LINQ to XSD preview illustrates our initial thinking on a strongly-typed programming experience over LINQ to XML. Instead of working with untyped XML trees, LINQ to XSD allows you to program in terms of strongly-typed classes, generated based on an XSD schema." Follow this link to get the details and download information.

Posted Thursday, January 15, 2009 3:24 PM by Amir Zuker | 2 comment(s)

תגים:,