New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of linq
Dim fc As New System.Drawing.Text.InstalledFontCollection
Fonts = (From x In Enumerable.Range(0, fc.Families.Count) _
         Select New With {.Id = x + 1, _
                          .Name = fc.Families(x).Name, _
                          .SortOrder = (x + 1) * 100}).ToList
fc = Nothing
by Thom Lamb   June 30, 2010 @ 10:54am
Tags: .Net, VB, Fonts, Linq
22 Views
no comments
 
C#
// Define a list by enclosing the item type in brackets [int]
// and initialize its value.
 
Scores : [int] = [ 92, 100, 85, 62, 81, 100 ];
 
// Option A
 
// require the stream type to be specified on a property
PassingScores : int*
{
by Dan Vanderboom   June 16, 2010 @ 1:07pm
55 Views
no comments
 
C#
var results = 
    from e in exposureGrouping
    group e by new { e.Category, e.Area } into g
    orderby g.Key.Category, g.Key.Area
    select new WorldwideExposure
    {
        Category = g.Key.Category,
        Area = g.Key.Area,
        Open_Market = g.Where(x => x.ClassCode == "OM").Sum(x => x.Usd_Gross_Exposure),
        North_American_Binders = g.Where(x => x.ClassCode == "NA").Sum(x => x.Usd_Gross_Exposure),
by Cat   June 16, 2010 @ 1:47am
Tags: C#, LINQ
48 Views
no comments
 
C#
var groupedResults =
    from r in results
    group r by r.Category into g
    select new
    {
        Category = g.Key,
        Results = g
    };
 
by Cat   June 16, 2010 @ 1:42am
Tags: C#, LINQ
20 Views
no comments
 
C#
var list = new PolicyPerilService()
    .GetAll()
    .Select(item => new { Code = item.Code, Description = item.Description})
    .ToList();
by Cat   June 01, 2010 @ 4:58am
Tags: LINQ
50 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using LinqToTree;
 
namespace AdomdClient.Data
{
by Bobby Diaz   May 20, 2010 @ 3:08pm
27 Views
no comments
 
C#
/// <summary>
/// Implements a projection strategy that select an "identity" property from an object 
/// and uses the default comparer to implement IEqualityComparer<typeparamref name="T"/>
/// </summary>
/// <typeparam name="T">Type of object to extract identity from</typeparam>
/// <typeparam name="TRet">Type of the extracted identity value</typeparam>
public class IdentityProjectionEqualityComparer<T, TRet> : IEqualityComparer<T> where TRet : IComparable<TRet>
{
    private readonly Func<T, TRet> _projector;
    private readonly IEqualityComparer<TRet> _comparer;
by Marc Brooks   May 18, 2010 @ 2:26pm
161 Views
2 comments
 
C#
public IQueryable<T> Query(Expression<Func<T, bool>> predicate)
{
    IQueryable<T> returnValue;
    using (ITransaction transaction = _session.BeginTransaction())
    {
        try
        {
            returnValue = _session.Linq<T>().Where(predicate);
            transaction.Commit();
        }
by Chris Brandsma   May 14, 2010 @ 2:09pm
45 Views
no comments
 
C#
public interface ICriteriaQuery<TEntity>
{
    DetachedCriteria Criteria { get; }
}
 
public interface ILinqQuery<TEntity>
{
    Expression<Func<TEntity, bool>> Expression { get; }
}
by Liam   May 13, 2010 @ 10:40pm
58 Views
no comments
 
C#
class Program
{
    static void Main(string[] args)
    {
        List<Person> people = new List<Person>();
        people.Add(new Person() { FirstName = "John", LastName = "Doe"});
        people.Add(new Person() { FirstName = "Jane", LastName = "Doe" });
        people.Add(new Employee() { FirstName = "John", LastName = "Smith" });
 
        // Displays 3
by JamesEggers   April 21, 2010 @ 6:03am
Tags: LINQ
30 Views
no comments
 
C#
public static IEnumerable<TSource> Distinct<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector)
{
    return source.Distinct(new SelectorEqualityComparer<TSource, TKey>(selector));
}
by Paulo Morgado   April 10, 2010 @ 5:22am
65 Views
no comments
 
C#
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, bool> predicate)
{
    return source.Distinct(new PredicateEqualityComparer<TSource>(predicate));
}
by Paulo Morgado   April 10, 2010 @ 5:21am
71 Views
no comments
 
C#
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
 
namespace OverlapClipProjectionWithLinq
{
    [TestClass]
    public class RangeExtensions_Resolve_Tests
    {
        private static readonly GenericEqualityComparer<Range> Comparer = new GenericEqualityComparer<Range>((x, y) => x.Begin == y.Begin && x.End == y.End, x => x.Begin.GetHashCode() * x.End.GetHashCode() * 2);
by cromwellryan   March 30, 2010 @ 10:12pm
Tags: linq
41 Views
no comments
 
C#
/// <summary>
/// Determine if the specified string is blank, where blank is defined 
/// as null, empty or containing only whitespace characters.
/// </summary>
/// <param name="value">string to be evaluated</param>
/// <returns>
/// true if the value is null, empty or contains only 
/// whitespace characters; otherwise false
/// </returns>
static bool IsNullOrWhiteSpace(string value)
by Al Gonzalez   March 15, 2010 @ 11:05am
Tags: String, LINQ, Any
71 Views
no comments
 
C#
/// <summary>
/// Returns a page worth of items from the specified collection.
/// </summary>
/// <typeparam name="TSource">the type of the items in the collection</typeparam>
/// <param name="source">an IEnumerable&gt;TSource&lt; of items to page</param>
/// <param name="pageNumber">the number of the page to return</param>
/// <param name="itemsPerPage">the number of items that make up a page</param>
/// <returns>
/// An IEnumerable&gt;TSource&lt; the contains the specified number of items for the specified pageNumber. 
/// If pageNumber exceeds the number of available pages, the returned collection will be empty.
by Al Gonzalez   March 15, 2010 @ 9:59am
Tags: LINQ, Skip, Take, Paging
66 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Runtime.Serialization;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq.Expressions;
by Jerry Nixon   March 05, 2010 @ 9:36am
Tags: C#, LINQ, LINQ2SQL
360 Views
no comments
 
C#
public IResult GetResultTree()
{
    return new WebServiceResult<CampaignSessionBeanClient, GetCampaignTreeResultCompletedEventArgs>(x => x.GetCampaignTreeResultAsync(GetCampaignFilter()), x =>
    {
        var propsals = new ProposalMapper().MapMany(x.Result);
        var Agencies = from agc in propsals
                       group agc by agc.Agency.OrgOrgRoleId into agcGroup 
                       select new
                       {
                           OrgOrgRoleIdAgc = agcGroup.Key,
by Hadi Eskandari   February 19, 2010 @ 11:20pm
75 Views
no comments
 
    For Each item As String In From number In Split(text, " ") Order By number Select number
      If Not String.IsNullOrEmpty(item) AndAlso item.Length <= 20 Then ticketNumbers.Add(item)
    Next
by Martin Harris   February 08, 2010 @ 5:48pm
Tags: LINQ
84 Views
no comments
 
C#
using System.Collections.Generic;
using System.Linq;
using Caliburn.PresentationFramework.ApplicationModel;
using CWS.Application.Rounds.Model;
using Db4objects.Db4o;
 
namespace CWS.Application.Rounds.Presenters
{
    public class SectionPresenter : Presenter, ISectionPresenter
    {
by Andy Sherwood   February 01, 2010 @ 7:02pm
81 Views
no comments
 
C#
ParameterExpression pc = Expression.Parameter(typeof(Customer), "c");
 
IQueryable<Customer> q3 =
    dc.Customers.Where<Customer>
    (
        Expression.Lambda<Func<Customer, bool>>
        (
            Expression.Equal(
            Expression.Property(pc, typeof(Customer).GetProperty("City")),
            Expression.Constant("London", typeof(string))
by Iver   January 19, 2010 @ 8:13pm
Tags: Linq
107 Views
no comments
 
C#
public List<PersonInOrganization> ExtractInvalidEmails()
{
  EntityCollection<PersonInOrganization> list =  GetAllItems();
 
  //my first LINQ use!
  var invalids = from l in list where !string.IsNullOrEmpty(l.Email) && !IsValidEmail(l.Email) select l;
 
  return invalids.ToList<PersonInOrganization>();
}
by afsharm   January 12, 2010 @ 12:01am
95 Views
1 comments
 
Module Module1
 
    Sub Main()
        Dim InputXml = <?xml version="1.0" encoding="utf-8"?>
                       <users>
                           <user id="1" name="Eduardo"/>
                           <user id="2" name="Luciano"/>
                           <user id="3" name="Ricardo"/>
                       </users>
91 Views
no comments
 
C#
foreach (var group in groups)
                {
                    if (group.AllowsPermission(permissionType))
                    {
                        cache.Put(cacheKey, new List<bool> {true});
                        return true;
                    }
                }
 
by Steven Burman   December 23, 2009 @ 4:48pm
94 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using LinqExtender.Configuration.Serialization;
 
namespace LinqExtender.Configuration
{
    /// <summary>
by Athens Springer   December 17, 2009 @ 10:14pm
Tags: LINQ
61 Views
no comments
 
C#
using LinqExtender.Configuration.Serialization;
 
namespace LinqExtender.Configuration
{
    /// <summary>
    /// Fluent generic entry point for configuration settings.
    /// </summary>
    /// <typeparam name="T">query object</typeparam>
    public class Extender<T> : IClassSettings<T>
    {
by Athens Springer   December 17, 2009 @ 10:13pm
Tags: LINQ
44 Views
no comments
 
brought to you by:
West Wind Techologies


If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate