Format:
Recent snippets matching tags of LINQ
/// <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)
24 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.
13 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;
18 Views
no comments
// 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>");
12 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,
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
31 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 {
52 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))
49 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>(); }
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
foreach (var group in groups) { if (group.AllowsPermission(permissionType)) { cache.Put(cacheKey, new List<bool> {true}); return true; } }
61 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>
34 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> {
20 Views
no comments
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
101 Views
no comments
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;
26 Views
no comments
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.
84 Views
no comments
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
53 Views
no comments
// 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);
105 Views
no comments
// 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;
172 Views
no comments
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
58 Views
no comments
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 + "!";
76 Views
no comments
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); }
132 Views
no comments
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)
152 Views
no comments
public static class XmlExtensions { #region internal class XmlTranslator internal class XmlTranslator { private readonly StringBuilder _xmlTextBuilder; private readonly XmlWriter _writer; private XmlTranslator()
327 Views
no comments
/// <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>
43 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
