Format:
Recent snippets matching tags of linq
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; }
32 Views
no comments
// Format names as one comma delimited string var names = string.Join(", ", (from p in people select d.Name).ToArray());
47 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
62 Views
no comments
// 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
37 Views
no comments
////////////////////////////////////////////////////////////////////////////////////////////////////////// // Create the query var custs = from c in XElement.Load("Customers.xml").Elements("Customers") select c ; // Execute the query foreach (var customer in custs)
74 Views
no comments
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>() {
148 Views
no comments
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" }, };
198 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
124 Views
no comments
/// <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()) {
104 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
182 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
258 Views
no comments
#Region " Import Declaratives " Imports System.ComponentModel Imports System.Data.Linq Imports System.Data.Linq.Mapping Imports System.Reflection #End Region
231 Views
no comments
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)
108 Views
no comments
// 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 };
214 Views
no comments
// 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 }));
167 Views
no comments
namespace LINQY { class Program { static void Main(string[] args) { var filters = new List<int> { 1, 5 }; var objects = new List<A> {
143 Views
no comments
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)) {
203 Views
no comments
using System; using System.Linq.Expressions; public static class Aaa { public class A { public string NameField; }
177 Views
no comments
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" });
169 Views
no comments
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 };
165 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
