CodePaste Logo
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#
public static IEnumerable<Orders> ExcludeOrderTypes(this IEnumerable<Orders> orders, int[] orderTypeIdsToExclude)
{
 
    if ((orders == null || orders.Count == 0)) {
        return new List<Orders>();
    }
 
    if ((orderTypeIdsToExclude == null)) {
        return orders;
    }
by Cat   October 30, 2011 @ 11:07pm
Tags: C#, LINQ, Exclude
33 Views
no comments
 
C#
// Format names as one comma delimited string
var names  = string.Join(", ", (from p in people select d.Name).ToArray());
by Cat   October 30, 2011 @ 3:31pm
Tags: C#, LINQ
50 Views
no comments
 
Dim funcs = (From x In [Enum].GetValues(GetType(SummaryFunc)) _
Order By x _
Select New With {.ID = CInt(x), .Name =
[Enum].GetName(GetType(SummaryFunc), x)}).ToList
by Thom Lamb   October 02, 2011 @ 10:15am
Tags: vb, .net, Linq, enum
65 Views
no comments
 
C#
// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace SimpleLinqToObjects
by Sean Mahan   September 16, 2011 @ 6:55am
37 Views
no comments
 
C#
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
// Create the query 
var custs = from c in XElement.Load("Customers.xml").Elements("Customers") 
          select c ;
 
// Execute the query 
foreach (var customer in custs) 
by Jelana   August 11, 2011 @ 4:15am
Tags: xml, linq
77 Views
no comments
 
C#
void Main()
{
   List<Budget> list1 = new List<Budget>() {
      new Budget { SeasonNo = "1", SeasonName = "Test 1", typeProductCd = "3", UsdActualRetail = 1.01m },
      new Budget { SeasonNo = "1", SeasonName = "Test 2", typeProductCd = "3", UsdActualRetail = 1.01m },
      new Budget { SeasonNo = "1", SeasonName = "Test 3", typeProductCd = "3", UsdActualRetail = 1.01m },
      new Budget { SeasonNo = "1", SeasonName = "Test 4", typeProductCd = "3", UsdActualRetail = 1.01m },
   };
   
   List<Budget> list2 = new List<Budget>() {
by mellamokb   July 15, 2011 @ 4:04pm
153 Views
no comments
 
C#
void Main()
{
    AutoMapper.Mapper.CreateMap<Contact, KeyValuePair<Guid, string>>()
        .ConstructUsing(x => new KeyValuePair<Guid, string>(x.Id, x.FullName));
 
    //var contacts = ContactRepository.GetAll(); // Returns IList<Contact>
    var contacts = new List<Contact> {
        new Contact { Id = Guid.NewGuid(), FullName = "Joe Bob" },
        new Contact { Id = Guid.NewGuid(), FullName = "Sally Jones" },
    };
by mellamokb   July 15, 2011 @ 2:54pm
203 Views
no comments
 
''' <summary>
''' An Extension of the ControlCollection
''' </summary>
''' <param name="controls"></param>
''' <returns>An Enumerable collection of all of the controls in a ControlCollection</returns>
''' <remarks></remarks>
<Extension()> _
Public Function All(ByVal controls As ControlCollection) As IEnumerable(Of Control)
    Dim results As New List(Of Control)
    For Each Control As Control In controls
by Thom Lamb   June 13, 2011 @ 10:39am
127 Views
no comments
 
C#
/// <summary>
/// Ber saman hvaða síður eru í db og online, skilar lista yfir þær síður sem vantar í gagnagrunninn
/// </summary>
/// <returns></returns>
public List<page> GetPagesOnlineNotInDb()
{
    try
    {
        using (var db = new ExpectusSupportEntities())
        {
by Sigurður Bjarnason   June 12, 2011 @ 10:46am
Tags: linq, c#
106 Views
no comments
 
        Partial MustInherit Class InformationSchema
            Inherits System.Data.Linq.DataContext
 
            Private Shared mappingSource As System.Data.Linq.Mapping.MappingSource = New AttributeMappingSource
 
#Region " Constructors "
 
            Public Sub New(ByVal connection As String)
                MyBase.New(connection, mappingSource)
            End Sub
by Thom Lamb   June 09, 2011 @ 8:44am
185 Views
no comments
 
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Linq
Imports System.Data.Linq.Mapping
Imports System.IO
Imports System.Linq
Imports System.Text
Imports System.Diagnostics
Imports System.Reflection
by Thom Lamb   June 09, 2011 @ 8:40am
266 Views
no comments
 
 
#Region " Import Declaratives "
 
Imports System.ComponentModel
Imports System.Data.Linq
Imports System.Data.Linq.Mapping
Imports System.Reflection
 
#End Region
by Thom Lamb   April 08, 2011 @ 11:02am
235 Views
no comments
 
C#
class PowerSet
{
    static void Main(string[] args)
    {
        var set = Enumerable.Range(0, 8);
        foreach (var subSet in PowerSets(set))
            Console.WriteLine(String.Join(" ", subSet));
    }
 
    private static IEnumerable<IEnumerable<T>> PowerSets<T>(IEnumerable<T> masterSet)
by ccmouse   April 01, 2011 @ 8:11pm
110 Views
no comments
 
C#
// Linq to LLBLGen Pro 
LinqMetaData metaData = new LinqMetaData(adapter);
var q = from c in metaData.Customer
        select new
        {
            c.CustomerId,
            IsAmerican = (c.Country == "USA"),
            c.Country
        };
        
by Frans Bouma   March 17, 2011 @ 8:28am
216 Views
no comments
 
C#
// In memory list of objects
var idList = new List<Pair<int, int>>();
idList.Add(new Pair<int, int>() { Value1 = 10254, Value2 = 13 });
idList.Add(new Pair<int, int>() { Value1 = 10254, Value2 = 14 });
idList.Add(new Pair<int, int>() { Value1 = 10254, Value2 = 15 });
 
// Linq to LLBLGen Pro
LinqMetaData metaData = new LinqMetaData(adapter);
var q = metaData.OrderDetail
                    .Where(od => idList.Contains(new Pair<int, int>() { Value1 = od.OrderId, Value2 = od.ProductId }));
by Frans Bouma   March 03, 2011 @ 7:59am
170 Views
no comments
 
C#
namespace LINQY
{
    class Program
    {
        static void Main(string[] args)
        {
            var filters = new List<int> { 1, 5 };
 
            var objects = new List<A>
            {
by Darren Neimke   January 17, 2011 @ 3:34pm
Tags: linq
145 Views
no comments
 
C#
namespace Test
{
public static class MyExtensions
{
    public static IEnumerable<T> Where<T> (this IEnumerable<T> source, Func<T, bool> predicate)
    {
        foreach(var item in source)
        {
            if(predicate(item))
            {
by Vijay Sharma   January 06, 2011 @ 8:11am
207 Views
no comments
 
C#
using System;
using System.Linq.Expressions;
 
public static class Aaa
{
    public class A
    {
        public string NameField;
    }
by b1gbr0   October 26, 2010 @ 3:30am
177 Views
no comments
 
C#
static readonly List<Author> quotes = new List<Author>();
 
        public static void GetAuthors()
        {
            quotes.Add(new Author() { AuthorInfo = "", FirstName = "Devin", LastName = "Rader" });
 
            quotes.Add(new Author() { AuthorInfo = "", FirstName = "Bill", LastName = "Evjen" });
 
            quotes.Add(new Author() { AuthorInfo = "", FirstName = "Devin", LastName = "Rader" });
by Zubair   September 29, 2010 @ 10:39am
169 Views
no comments
 
C#
 
Foo foo1 = new Foo(),
    foo2 = new Foo(),
    foo3 = new Foo(),
    foo4 = new Foo();
 
foo1.Foos = new List<Foo> { foo2 };
foo2.Foos = new List<Foo> { foo2, foo3, foo4 };
 
var list = new List<Foo> { foo1, foo2 };
by InfinitiesLoop   August 27, 2010 @ 6:28pm
Tags: linq
167 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