Click here to Skip to main content
Click here to Skip to main content

Tagged as

LINQ to memory objects in the .NET Compact Framework

, 19 Dec 2010
Rate this:
Please Sign up or sign in to vote.
LINQ to memory objects in the .NET Compact Framework
Language-Integrated Query (LINQ) adds general-purpose query facilities to the .NET Compact Framework that apply to various sources of information such as relational databases, XML data, and in-memory objects,
 
Here we define the LINQ to memory objects, we use list data type as the memory object to hold the data.
 
Entity.cs Class
 
using System;
using System.Collections.Generic;
using System.Linq;
namespace LINQ_test
{
    public  class entity
    {
 
        public   string name
        {
            get;
            set;
        }
    }
}
 
//Linq form 

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
 
namespace LINQ_test
{
    public partial class Linq : Form
    {
        List<entity> li = new List<entity>();
        
        public Linq()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {           
           entity er= new entity();
           er.name = textBox1.Text;
           li.Add(er);
 
           textBox1.Text = "";
           ArrayList Alist = new ArrayList();
           var varlinq = from p in li where p.name.Length < 4
                     select p;
 
            foreach (var data in varlinq)
 
            Alist.Add(data);
 
            dataGrid1.DataSource =  Alist;           
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            ArrayList  Alist = new ArrayList();
            var varlinqnext = from p in li
                     select p;
 
            foreach (var data in varlinqnext)
 
               Alist.Add(data);
 
            dataGrid1.DataSource = Alist;             
        }
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

SuhasHaridas
Software Developer Standout IT Solutions(P) Ltd.
India India
My name is SuhasHaridas.
 
I'm a Software Engineer in the .NET Developer Platform group within the Developer Division at Standout IT Solutions(P) Ltd.
I have focused on the Web platform during these years.Specifically, that means I have worked on ASP.NET and c#.NET ,SharePoint,Sql, WCS Apps(Cisco Wireless Control System),.NET Compact Framework, LINQ , ADO.NET , Ado.net entity framework ,Silverlight , WCF Services , SQL SQLCE Visual Studio and Visual Studio Web Developer as well as on IIS7.
Follow on   Twitter   Google+

Comments and Discussions

 
GeneralDooper Super Pinmemberjfriedman16-Dec-10 9:22 
GeneralRe: Dooper Super PinmemberSuhasHaridas13-Aug-12 0:16 
Generalcode Pinmembervinuxlnt13-Dec-10 18:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 19 Dec 2010
Article Copyright 2010 by SuhasHaridas
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid