.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Error in linq to sql assembliy

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net


 I am building N-Tier Architecture. I am using throught linq to sql. In businessLogicLayer i am getting error like this

Error    64    The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 

where should i add this reference in my Business Logic layer.

plz help me.


View Complete Post

More Related Resource Links

linq and max, if return null return error


hi there
i have this query :

var result2 = (from TH in DB.Threshold
                          where TH.ProductSKUID == int.Parse(HID_ProductSKUID.Value)
                          select TH.ThresholdID).Max();

the problem is that if this query does not find any items, return null, so thow exception
how can i do to return 0??

Cast error when inserting record with Linq (to Sql)



I'm getting  the following error message: 

Unable to cast object of type 'System.Data.Linq.DataQuery`1[Username]' to type 'Username'.

I've been searching but can't find a solution.  This particular table has 4 columns. The first column is the int indentifier.  Column 2 is "username" (varchar50) and is the primary key.  Column3 is "userID" (uniqueidentifier) and column 4 is "active" (varchar5) .

            Dim dc As New DataClassesDataContext
            Dim c3 As New Username With {.userID = userGuid, _
                                    .username = userCustomName, _
                                    .active = "False"}


        Catch ex As Exception
            Throw ex
        End Try


LINQ to SQL compiler error CS1519: Invalid token 'void' in class, struct, or interface member decl

I get the following compiler errors when creating my first LINQ to SQL class (I just dragged a table "ProfileExtended" onto the designer and hit build):DataClasses.designer.cs(31,11): error CS1519: Invalid token 'void' in class, struct, or interface member declaration these are the offending lines of autogenerated code:#region Extensibility Method Definitions  partial void OnCreated();  partial void InsertProfileExtended(ProfileExtended instance);  partial void UpdateProfileExtended(ProfileExtended instance);  partial void DeleteProfileExtended(ProfileExtended instance);  #endregion

LINQ Error

Dear all, I have below code. But It throw exception that System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Cannot order by type System.Object.    at System.Data.Linq.SqlClient.QueryConverter.VisitOrderBy(Expression sequence, LambdaExpression expression, SqlOrderType orderType)    at System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)    at System.Data.Linq.SqlClient.QueryConverter.VisitMethodCall(MethodCallExpression mc)    at System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)    at System.Data.Linq.SqlClient.QueryConverter.ConvertOuter(Expression node)    at System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations)    at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)    at System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)   public List<KeyValue> GetStockTypes()        { &nbs

cannot convert string to bool error in LINQ


hi guys,

this is my code:

DataClassesDataContext db = new DataClassesDataContext();
        item it = new item();

        var items = from p in db.items
                    where p.id = TextBox1.Text
                    select p;

        GridView1.DataSource = items;

an error message at line 5 says:

  Cannot implicitly convert type 'string' to 'bool'

the id attribute on the items table is of varchar(50) type. and the text box too is of string type.

so why does it says conversion between boolean and string problem?

thank you all.

Object Must Implement IConvertible error in LINQ to Entities with group by

1 down vote favorite

Hi. I have an ASP.NET MVC application in which i am using entity model for connecting to MySQl database

Here I am joining 2 tables and then applying group by on one of the fields. Then fetching the result from GroupBy result. Everything is working fine on development machine but getting  error:

"Object Must Implement IConvertible"   when executing on the stagging server.

Can you please help me out why such error is occurring. I have taken the dump of database form staging server and then used that on development machine then also working fine. But when I placed the dump of development machine database on staging then getting the same exception.

So where is problem i am not understanding.

The model structure is



Here student and st

LINQ error if function


            tbl_PotniNalogi potninalogi = new tbl_PotniNalogi()
                        if (Session["ID"] != null)
            Button1.Text = Convert.ToString((int)Session["ID"]);

                Stevilka = MaxStevilka + 1,
                Leto = Convert.ToString(DateTime.Now.Year),
                DatumIzdaje = txtDatum.SelectedDate.Value,
                Voznik = ddlVoznik.Text,
                NaslovVoznika = "Cankarjeva 9",
                SluzbenoVozilo = Convert.ToBoolean("True"),
                Vozilo = ddlVozilo.Text,
                Odredil = ddlOdredil.Text,
                ZacetnoStanje = Convert.ToInt32(txtZacetnoStanje.Text),
                KoncnoStanje = Convert.ToInt32(txtKoncnoStanje.Text),

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1513: } expected

Source Error:


Error: cannot be translated into a LINQ to Entities store expression


When I run my code i get this error:

The specified method '{0}' on the type '{1}' cannot be translated into a LINQ to Entities store expression

it happens in this part of the code:

 public Boolean valtOpVerlofDag(Dictionary<string, object> afw)
            DateTime start = DateTime.Parse((string)afw["startDatum"]);
            IEnumerable<Period> holidays = from hol in periods
                                               where (hol.Type == "Holiday") && hol.IsInPeriod(start)
                                               select hol;
            if (holidays.Count() == 0)

Playing with Linq grouping: GroupByMany?

One of its features is grouping. Many people understand grouping like it is defined in Sql. Linq is implementing grouping quite the same way. Let's discover this syntax and how to make consecutive groups easier.

LINQ : Implementing IN and NOT IN

I got tried of typing

var result = from s in source
where items.Contains(s)
select s;and so I implemented the IN and NOT IN methods as extension methods:

101 LINQ Samples Tutorials

101 LINQ Example with sample code snippets....This sample prints each element of an input integer array whose value is less than 5. The sample uses a query expression to create a new sequence of integers and then iterates over each element in the sequence, printing its value

Linq: how to share parameters between lambda expressions ?

When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it's not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not visible from one method to another.
The compiler is using two technical different ways to let parameters go out of a method.

Linq to Sql CompiledQuery container

Ok now let's go. Here is just a little trick but with some interesting patterns that could be useful in some other contexts not connected to Linq to Sql.

When using Linq expressions, like with Linq to Sql, translating the expression into something else (sql for example) is taking time and resources. Sometimes it's negligible, sometimes not...

LINQ to SQL Paging using GridView in C# and ASP.NET 3.5

This tutorial will show you how we can extend the LINQ to SQL Class and create methods that will allow us to page data from a SQL database. C# version.

What is Lambda Expressions In LINQ

A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.

All lambda expressions use the lambda operator =>, which is read as "goes to". The left side of the lambda operator specifies the input parameters (if any) and the right side holds the expression or statement block. The lambda expression x => x * x is read "x goes to x times x." This expression can be assigned to a delegate type as follows:

How to create 3 tier application using LINQ

As you know that in 3 tier architecture there are three layers

User interface layer. (Is our Form in Windows application and .aspx page in Web application)
Data Access layer. (Which provides interface between Business logic layer and Database)
Business Logic layer.(Which stores your application logic)

Building a LINQ Provider

Throughout this article, we will build a simple IQueryable provider similar to the LINQ to SQL provider demonstrating what is needed to build a custom provider that is capable of executing LINQ queries and performing create, update and delete operations.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend