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
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   Today @ 11:05am
Tags: String, LINQ, Any
24 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   Today @ 9:59am
Tags: LINQ, Skip, Take, Paging
13 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
18 Views
no comments
 
C#
// Simple html page where I got 3 links, the first 1 doesn't follow the same structure as the two others.
// The two others are the ones that I am interested in, based on my query I want to search for either Golf or Football and If I
// if it match my query I want to get the link above it. So if I want to search for Gold I want to get the link with the href = "TheUrlIWant"
StringBuilder builder = new StringBuilder();
builder.Append("<html><head></head><body>");
builder.Append("<h1>Screen Scraping practice</h1>");
builder.Append("<a href=" + (char)34 + "someurl" + (char)34 + " >Some random url on the site</a>");
builder.Append("<b>");
builder.Append("<a class=" + (char)34 + "visit" + (char)34 + " href=" + (char)34 + "TheUrlIDontWant" + (char)34 + " >Item</a>");
builder.Append("</b>");
February 25, 2010 @ 11:16am
12 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
32 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
31 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
52 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
49 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
39 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>
51 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
61 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
34 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
20 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
using System.Linq;
using LinqExtender.Attributes;
using LinqExtender.Configuration.Serialization;
using LinqExtender.Interfaces;
 
namespace LinqExtender
by Athens Springer   December 17, 2009 @ 10:10pm
Tags: LINQ
101 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Collections;
using System.Reflection;
using LinqExtender.Collection;
using LinqExtender.Interfaces;
by Athens Springer   December 17, 2009 @ 10:09pm
Tags: LINQ
26 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using LinqExtender.Interfaces;
 
namespace LinqExtender
{
    /// <summary>
    /// Generates a new object from existing one using the user's setup.
by Athens Springer   December 17, 2009 @ 8:59pm
Tags: LINQ
84 Views
no comments
 
C#
var result =
    from order in dtx.Orders
    join confirmation in dtx.Confirmations
        on order.acctPoNumId equals confirmation.acctPoNumId into transactions
        from transaction in transactions.DefaultIfEmpty()
        join store in dtx.Stores
            on transaction.indexOfStore equals store.storeIndex into xStores
            from xstore in xStores
            join chain in dtx.Chains
                on xstore.indexOfChain equals chain.chainIndex into xChains
by PLangeberg   November 06, 2009 @ 7:28pm
Tags: Linq
53 Views
no comments
 
C#
// I keep getting a 401 NOT AUTHORISED when i do the following.
 
public void StatusUpdate(string message, string accessToken)
{
    // Custom extension methods for argument checking. (This works fine.)
    message.ThrowIfArgumentIsNullOrEmpty("message");
    accessToken.ThrowIfArgumentIsNull("accessToken");
 
    // Create an authorization instance. This works.
    var authorization = new WebOAuthAuthorization(_twitterTokenManager, accessToken);
by PK   October 24, 2009 @ 5:22am
105 Views
no comments
 
C#
// works as expected
public wws_Item LoadBySku(string sku)
{
    Expression< Func<wws_Item, bool> > func = itm => itm.Sku == sku;
 
    Entity = Context.wws_Items.Where(func).SingleOrDefault();
    if (Entity != null)
        OnLoaded(Entity);
 
    return this.Entity;
by Rick Strahl   October 04, 2009 @ 5:02pm
172 Views
no comments
 
C#
private readonly SortedList<Distance, List<BearingPoint>> pointsByX;
private readonly SortedList<Distance, List<BearingPoint>> pointsByY;
 
 
...
 
Point targetPoint;
var bestMatch = 
   (from pt in 
    (from kvp in pointsByX
by mikecvelide   September 28, 2009 @ 11:34am
58 Views
no comments
 
C#
 StockContext context = new StockContext();
 User user = context.Users.Where( uss => uss.Pk == 1).SingleOrDefault();
 Response.Write(user.FullName + "<br>"); 
 user.FullName = user.FullName + "!";
 
 
 StockContext context2 = new StockContext();
 User user2 = context.Users.Where(uss => uss.Pk == 1).SingleOrDefault();
 Response.Write(user2.FullName + "<br>");
 user2.FullName = user2.FullName + "!";
by Rick Strahl   September 27, 2009 @ 2:34pm
76 Views
no comments
 
C#
public interface IRepository<T, TPkType>
{
    IQueryable<T> Select();
    T SelectOnId(TPkType id);
    IQueryable<T> SelectPaged<TResult>(int pageIndex, int pageSize, Expression<Func<T, TResult>> sortExpression, bool isAscending);
    IQueryable<T> FindPaged<TResult>(int pageIndex, int pageSize, Expression<Func<T, bool>> findExpression, Expression<Func<T, TResult>> sortExpression, bool isAscending);
    IQueryable<T> Find(Expression<Func<T, bool>> expression);
    T Save(T item);
    void Delete(TPkType id);
}
by JeffSpicolie   September 24, 2009 @ 4:30pm
132 Views
no comments
 
C#
public interface IQuery<TResult>
{
    //Execute method that accepts an ObjectContext and returns a TResult
    TResult Execute(EntityContext context);
}
 
public abstract class QueryBase<TResult> : IQuery<TResult>
{
    //userCompiled parameter to decide whether to use compiled query or plain one
    protected QueryBase(bool useCompiled)
by Muhammad Mosa   September 05, 2009 @ 7:08pm
152 Views
no comments
 
C#
public static class XmlExtensions
{
    #region internal class XmlTranslator
 
    internal class XmlTranslator
    {
        private readonly StringBuilder _xmlTextBuilder;
        private readonly XmlWriter _writer;
 
        private XmlTranslator()
by Andy Sherwood   August 25, 2009 @ 9:56am
327 Views
no comments
 
C#
/// <summary>
/// Dictionary that serves as a cache for cached PropertyInfo[] arrays
/// </summary>
static Dictionary<Type, PropertyInfo[]> trimCache;
/// <summary>
/// This function trims all public properties on an Enumerable object 
/// except those specified as optional parameters
/// </summary>
/// <typeparam name="T">The type of object</typeparam>
/// <param name="sourceList">A list of items</param>
by Matthew M.   August 19, 2009 @ 4:15pm
43 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