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
22 Views
no comments
// 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* {
55 Views
no comments
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),
48 Views
no comments
var groupedResults = from r in results group r by r.Category into g select new { Category = g.Key, Results = g };
20 Views
no comments
var list = new PolicyPerilService() .GetAll() .Select(item => new { Code = item.Code, Description = item.Description}) .ToList();
50 Views
no comments
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Xml; using System.Xml.Linq; using LinqToTree; namespace AdomdClient.Data {
27 Views
no comments
/// <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;
161 Views
2 comments
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(); }
45 Views
no comments
public interface ICriteriaQuery<TEntity> { DetachedCriteria Criteria { get; } } public interface ILinqQuery<TEntity> { Expression<Func<TEntity, bool>> Expression { get; } }
58 Views
no comments
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
30 Views
no comments
public static IEnumerable<TSource> Distinct<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector) { return source.Distinct(new SelectorEqualityComparer<TSource, TKey>(selector)); }
65 Views
no comments
public static IEnumerable<TSource> Distinct<TSource>(this IEnumerable<TSource> source, Func<TSource, TSource, bool> predicate) { return source.Distinct(new PredicateEqualityComparer<TSource>(predicate)); }
71 Views
no comments
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);
41 Views
no comments
/// <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)
71 Views
no comments
/// <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>TSource< 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>TSource< 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.
66 Views
no comments
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;
360 Views
no comments
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,
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
84 Views
no comments
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 {
81 Views
no comments
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))
107 Views
no comments
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>(); }
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
foreach (var group in groups) { if (group.AllowsPermission(permissionType)) { cache.Put(cacheKey, new List<bool> {true}); return true; } }
94 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using LinqExtender.Configuration.Serialization; namespace LinqExtender.Configuration { /// <summary>
61 Views
no comments
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> {
44 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
