Category LINQ

Delete Rows from DataTable Using Linq in C#

Category: C#.NetLINQ Comments: No comments

Delete Rows from DataTable Using Linq in C#Read More

Update Field Value in DataTable using Linq in C#

Category: C#.NetLINQ Comments: No comments

Update Field Value in DataTable using Linq in C#Read More

Where Clause using in LINQ to Entities

Category: LINQ Comments: No comments

Entity Model Name  :

TestLinqDataContext db = new TestLinqDataContext();
var obj=from p in db. TagMasters
where p.TagCode == TextBox2.Text
select p;

Read More

Order by using in LINQ to Entities

Category: LINQ Comments: No comments

Entity Model Name  :

TestLinqDataContext db = new TestLinqDataContext();
var detail = from p in db.TagMasters
orderby p.ExpirationDate descending

Read More

Joins and Group By using in LINQ to Entities

Category: LINQ Comments: No comments

Entity Model Name  :

TestLinqDataContext db = new TestLinqDataContext();
var result = (from p in db.TagMasters
join
t in db.TagRegistrations on p.ID equals t.TagId
group t by new { p.TagCode, t.DateCreated } into g
select new { g.Key.TagCode,g.Key.DateCreated}).Distinct();

Read More

Top Operator using take in LINQ to Entities

Category: LINQ Comments: No comments

Entity Model Name  :

TestLinqDataContext db = new TestLinqDataContext();
var topDate = db.TagMasters.Take(3);

Read More

Sub query in LINQ to Entities

Category: LINQ Comments: No comments

Entity Model Name  :
TestLinqDataContext db = new TestLinqDataContext();

 

var innerQuery = (from fb in db. TagMasters orderby fb.ExpirationDate descending select fb.ExpirationDate).Take(3).Distinct();
var result = (from f in db.TagMasters
where innerQuery.Contains(f.ExpirationDate)
// Notice here, grouping by a constant value
group f by 1 into g
select g.Max(t => t.ExpirationDate) );

Read More

Like operator or using wildcards in LINQ to Entities

Category: LINQ Comments: No comments

Entity Model Name  :
TestLinqDataContext db = new TestLinqDataContext();

var obj = from p in db.TagMasters
where SqlMethods.Like(p.TagCode, “%” + TextBox2.Text + “%”)
select new {
p.TagCode,p.Status,p.ExpirationDate
};

Read More

Calling an stored procedure using ADO.NET Entity Model (Entity Framework LINQ to SQL)

Category: ASP.NETENTITY FRAMEWORKLINQ Comments: No comments

In this article I would like to share something regarding Entity Framework, how we can implement operations using Stored Procedures in Entity Framework. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Users]( [Uid] [int] IDENTITY(1,1) NOT NULL, [Fname] [nvarchar](50) NULL, [Lname] [nvarchar](50) NULL, [Email] [nvarchar](50) NULL, [Gender] [nvarchar](50) NULL, [Address] [nvarchar](50) NULL, CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED ( [Uid] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_NULLS ON GO Read More

Introduction to LINQ

Category: LINQ Comments: No comments

Language Integrated Query (LINQ) provides .NET developers some new and exciting features to query and manipulate data in a consistent and uniform way. It enables them to work with different type of data sources such as Arrays, collection of objects, XML documents, a relational databases, Active Directory or even Microsoft Excel sheets by writing or embedding queries in C# or Visual Basic language. Microsoft has introduced many new keywords and features in both C# and Visual Basic languages to integrate LINQ technology. Microsoft has also added new namespaces in .NET Framework Library that contains new interfaces and hundreds of extension methods also called LINQ query operators. These methods perform different operations on different type of data sources in LINQ. LINQ stands for Language-Integrated Query. Basically LINQ address the current database development model in the context of Object Oriented Programming Model. If some one wants to develop database application on .Net platform the very simple approach he uses ADO.Net. ADO.Net is serving as middle ware in application and provides complete object oriented wrapper around the database SQL.So developer must have good knowledge of object oriented concept as well as SQL to develop an application. But incase of Linq SQL statements are become part of the C# and VB.Net code so there are less chance of mistake.Read More