Search Results

Search found 114 results on 5 pages for 'linqtosql'.

Page 4/5 | < Previous Page | 1 2 3 4 5  | Next Page >

  • View Lambdas in Visual Studio Debugger

    - by Vaccano
    I have the a simple LinqToSQL statement that is not working. Something Like this: List<MyClass> myList = _ctx.DBList .Where(x => x.AGuidID == paramID) .Where(x => x.BBoolVal == false) .ToList(); I look at _ctx.DBList in the debugger and the second item fits both parameters. Is there a way I can dig into this more to see what is going wrong?

    Read the article

  • silverlight TypeDescriptor.GetConverter substitute

    - by luke
    I am trying to use the LINQtoSQL project in silverlight (its a great project), because its open sourced i figured i could just recompile as a silverlight class library but unfortunately it appears to use a feature not available in silverlight. The TypeDescriptor.GetConverter method. It uses this to find type converters to properly parse the csv columns to their corresponding CLR types. I have no problem making changes to the linqtocsv sources to make it work in Silverlight, but i just don't know what an equivalent operation would be in silverlight. Various google searches have brought me to this page, but all that says is that the XAML parser has a way of doing this (but it doesn't say how to access this functionality). In a nutshell, the question is: how do i replicate the functionality of TypeDescriptor.GetConverter?

    Read the article

  • Repository pattern - Switch out the database and switch in XML files

    - by glasto red
    Repository pattern - Switch out the database and switch in XML files. Hello I have an asp.net MVC 2.0 project and I have followed the Repository pattern. Periodically, I am losing access to the database server so I want to have another mechanism in place (XML files) to continue developing. It is not possible to have a local version of the db unfortunately! I thought this would be relatively easy using the Repository pattern, to switch out the db repositories and switch in XML versions. However, I am having real trouble coming up with a solution. I have tried LinqToXML but then ran into problems trying to return a List of News items as the LinqToXML ToList returns Generic.List Should I be mapping the XElement list over to the News list by hand? It just seems a bit clunky compared to LinqToSQL attributes on the News class and then simply doing a Table.....ToList(); Any direction would be appreciated. Thanks

    Read the article

  • [LINQ]InsertOnSubmit NullReferenceException

    - by Kurresmack
    Hello, I have a rather annoying issue with LinqToSql. I have created a class that is derived from the class in the DataContext. The problem is that as soon as I use "InsertOnSubmit(this);" on this derived class I get a NullReferenceException. I've seen some people with the same issue. However they've used a custom constructor and solved the issue by calling ": this()" like this thread http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/0cf1fccb-6398-4f16-920b-adef9dc4ac9f The difference is that I use a default constructor which causes the base constructor to be called so there should not be any problem! Could someone please help me with this, starts to get annoying! Thanks :)

    Read the article

  • How can I tell datacontext I've updated a record via StoreProcedure

    - by Ldsenow
    Hi Geeks, I've a stroe procedure to update a record and after running it I use LinqToSql to delete the record. I know it is weird but I just want to test how smart the datacontext it is and understand how it works. Since the datacontext caches the results so any change via it can be recorded but now I use a store procedure to update something, it would not know. So when I try to delete it, an exception comes out "Row not found or changed". How I can tell the datacontext what I have updated? If I can do so the problem will sovle.

    Read the article

  • Which layer should create DataContext?

    - by Kevin
    I have a problem to decide which layer in my system should create DataContext. I have read a book, saying that if do not pass the same DataContext object for all the database updates, it will sometimes get an exception thrown from the DataContext. That's why i initially create new instance of DataContext in business layer, and pass it into data access layer. So that the same datacontext is used for all the updates. But this lead to one design problem, if i wanna change my DAL to Non-LinqToSQL in future, i need to re-write the code in business layer as well. Please give me some advice on this. Thanks. Example code 'Business Layer Public Sub SaveData(name As String) Using ts AS New TransactionScope() Using db As New MyDataContext() DAL.Insert(db,name) DAL.Insert(db,name) End Using ts.Complete() End Using End Sub 'Data Access Layer Public Sub Insert(db as MyDataContext,name As string) db.TableAInsert(name) End Sub

    Read the article

  • ObjectDataSource DataObjectTypeName Help. Pass object as parameter

    - by Kettenbach
    I have a partial class (the main class is a LinqToSql generated class) <DataObject(True)> _ Partial Public Class MBI_Contract <DataObjectMethod(DataObjectMethodType.Select, True)> _ Public Shared Function GetCancelableContracts(ByVal dealer As Dealer) As List(Of MBI_Contract) Return Utilities.GetCancelableContractsForDealer(dealer) End Function End Class Here is the method it's calling Public Function GetCancelableContractsForDealer(ByVal dealer As Dealer) As List(Of MBI_Contract) Dim db As TestDataContext = TestDataContext.Create() Return (From mbi As MBI_Contract In db.MBI_Contracts _ Where mbi.MBI_DealerNumber = dealer.DealerNumber _ AndAlso mbi.MBI_PaidFor = True _ AndAlso mbi.MBI_Deleted = False).ToList() End Function I want to use the ObjectDataSource to drive a DropDownList. <asp:ObjectDataSource ID="contractOds" runat="server" TypeName="MBI_Contract" SelectMethod="GetCancelableContracts" DataObjectTypeName="Dealer"> </asp:ObjectDataSource> My aspx page has a Dealer property that is set in a BasePage. My question is how can I pass this property(object) to the ObjectDataSource, so it can be evaluated in my select method. Does anyone know how I can do this? Or am I totally doing this the wrong way? Thanks for any Advice, Cheers, ~ck in San Diego

    Read the article

  • ASP.NET MVC- Bizarre problem - suddennly lost all LINQTO SQL data context objects

    - by MikeD
    I was making an edit to a long existing project. Specifically I added some fields to a table and had to delete the table from the LINQTOSQL designer and re-add it. doesn't Also had to do the same for a view. Mode some other code changes and went to build . Now my project won't build because it can't resolve any of the data context objects (all tables and views) in my code. I don't know what I did or how this happeened. I have many tables and views in the project's L2S data context so I don't wont to try and do over. Please any suggestions on how to resolve this problem are greatly appreciated. Desparate! The error messages I am getting are the familiar The type or namespace name 'equipment' could not be found (are you missing a using directive or an assembly reference?)

    Read the article

  • Using Multiple Foreign Keys to the same table in LINQ

    - by Graeme
    I have a table Users and a table Items In the Items table, I have fields such as ModifiedBy CreatedBy AssignedTo which all have a userId integer. The database is set up to have these as foreign keys back to the Users table. When using LINQToSQL, the relationships which are automatically built from the dbml end up giving me names like User, User1 and User2 e.g. myItem.User1.Name or myItem.User2.Name Obviously this isn't very readable and I'd like it be along the lines of myItem.CreatedByUser.Name or myItem.ModifiedByUser.Name etc I could change the names of the relationships but that means I have to redo that every time I change the db schema and refresh the dbml. Is there any way round this?

    Read the article

  • Entity Framework, what's so bad and what's so good?

    - by AverageJoe719
    Hi all, I am curious as to what your opinions are in Entity Framework? I have read some things like the first version of it is super horrible because it doesn't handle many to many relationships (though many ORMs don't and I've never seen the issue with just making a linking table). Also is LINQ to Entities the same as Entity Framework? I think it is, but it seems like one term is used or the other. I have used Linq to SQL before, what are the advantages of it compared to that? In terms of coding preference I like to build everything from the ground up so I can fully understand it/be in control of the code I write. So I have heard that Entity Framework is harder and I know LinqToSQL handles a lot of stuff automatically, but specifically what are the differences? I appreciate your responses, Thanks =)

    Read the article

  • Nested WPF DataGrids

    - by jvberg
    I have a DataGrid (from the toolkit) and I want to nest another DataGrid in the DataGrid.RowDetailsTemplate. The trick is I want to bring back the data from one table in the main grid and then based on row selection go and get additonal detail from a different table and show it in the DataGrid in the detail template. This is easy enough to do in 2 seperate DataGrids but I am having trouble getting it to work with the nested version. Is this even possible? If so, could someone point me in the right direction. I should note I am using LinqToSql clases to populate the data. Thanks for your consideration. -Joel

    Read the article

  • how to convert Database Hierarchical Data to XML using ASP.net 3.5 and LINQ

    - by mahdiahmadirad
    hello guys! i have a table with hierarchical structure. like this: and table data shown here: this strategy gives me the ability to have unbounded categories and sub-categories. i use ASP.net 3.5 SP1 and LINQ and MSSQL Server2005. How to convert it to XML? I can Do it with Dataset Object and ".GetXML()" method. but how to implement it with LINQtoSQL or LINQtoXML??? or if there is another simpler way to perform that? what is your suggestion? the best way? I searched the web but found nothing for .net 3.5 featuers.

    Read the article

  • Cannot Translate to SQL using Select(x => Func(x))

    - by Dan
    I'm slowly learning the ins and outs of LINQtoSQL, but this is confusing me. Here is the statement I have: IQueryable<IEvent> events = (from e in db.getEvents() select e).Select(x => SelectEvent(x, null)); What the SelectEvent does can be explained in this answer here. I am not using the .toList() function as I don't want potentially thousands of records brought into memory. public IEvent SelectEvent(SqlServer.Event ev, EventType? type) { // Create an object which implements IEvent // I don't have the code in front of me, so forgive the lack of code } My question is really for the Select() method. I get the "Cannot translate to SQL" error and the Select() is listed in the error message. Clueless on this one :-/.

    Read the article

  • Count word occurrences in a text field with LINQ

    - by Yoann. B
    How can i get the occurrences count of a Word in a database text field With LINQ ? Keyword token sample : ASP.NET EDIT 4 : Database Records : Record 1 : [TextField] = "Blah blah blah ASP.NET bli bli bli ASP.NET blu ASP.NET yop yop ASP.NET" Record 2 : [TextField] = "Blah blah blah bli bli bli blu ASP.NET yop yop ASP.NET" Record 3 : [TextField] = "Blah ASP.NET blah ASP.NET blah ASP.NET bli ASP.NET bli bli ASP.NET blu ASP.NET yop yop ASP.NET" So Record 1 Contains 4 occurrence of "ASP.NET" keyword Record 2 Contains 2 occurrence of "ASP.NET" keyword Record 3 Contains 7 occurrence of "ASP.NET" keyword Collection Extraction IList < RecordModel (ordered by word count descending) Record 3 Record 1 Record 2 LinqToSQL should be the best, but LinqToObject too :) NB : No issue about the "." of ASP.NET keyword (this is not the goal if this question)

    Read the article

  • Linq To Sql Left outer join - filtering null results

    - by Harry
    I'd like to reproduce the following SQL into C# LinqToSql SELECT TOP(10) Keywords.* FROM Keywords LEFT OUTER JOIN IgnoreWords ON Keywords.WordID = IgnoreWords.ID WHERE (DomainID = 16673) AND (IgnoreWords.Name IS NULL) ORDER BY [Score] DESC The following C# Linq gives the right answer. But I can't help think I'm missing something (a better way of doing it?) var query = (from keyword in context.Keywords join ignore in context.IgnoreWords on keyword.WordID equals ignore.ID into ignored from i in ignored.DefaultIfEmpty() where i == null where keyword.DomainID == ID orderby keyword.Score descending select keyword).Take(10); the SQL produced looks something like this: SELECT TOP (10) [t0].[DomainID], [t0].[WordID], [t0].[Score], [t0].[Count] FROM [dbo].[Keywords] AS [t0] LEFT OUTER JOIN (SELECT 1 AS [test], [t1].[ID] FROM [dbo].[IgnoreWords] AS [t1]) AS [t2] ON [t0].[WordID] = [t2].[ID] WHERE ([t0].[DomainID] = 16673) AND ([t2].[test] IS NULL) ORDER BY [t0].[Score] DESC How can I get rid of this redundant inner selection? It's only slightly more expensive but every bit helps!

    Read the article

  • ASP.NET Thread Safety in aspx.cs code behind file

    - by Tim Michalski
    I am thinking of adding a DataContext as a member variable to my aspx.cs code-behind class for executing LinqToSql queries. Is this thread safe? I am not sure if a new instance of this code-behind class is created for each HTTP request, or if the instance is shared amongst all request threads? My fear is that I will get 10 simultaneous concurrent http requests that will be using the same database session. public partial class MyPage : System.Web.UI.Page { private DataContext myDB = new DataContext(); protected void MyAction_Click(object sender, EventArgs e) { myDB.DoWork(); } }

    Read the article

  • LINQ-to-SQL: Searching against a CSV

    - by Peter Bridger
    I'm using LINQtoSQL and I want to return a list of matching records for a CSV contains a list of IDs to match. The following code is my starting point, having turned a CSV string in a string array, then into a generic list (which I thought LINQ would like) - but it doesn't: Error Error 22 Operator '==' cannot be applied to operands of type 'int' and 'System.Collections.Generic.List<int>' C:\Documents and Settings\....\Search.cs 41 42 C:\...\ Code DataContext db = new DataContext(); List<int> geographyList = new List<int>( Convert.ToInt32(geography.Split(',')) ); var geographyMatches = from cg in db.ContactGeographies where cg.GeographyId == geographyList select new { cg.ContactId }; Where do I go from here?

    Read the article

  • System.Linq.Dynamic and DateTime

    - by Matthew Hood
    I am using System.Linq.Dynamic to do custom where clauses from an ajax call in .Net MVC 1.0. It works fine for strings, int etc but not for DateTime, I get the exception cannot compare String to DateTime. The very simple test code is items = items.Where(string.Format(@" {0} {1}{2}{1} ", searchField, delimiter, searchString)); Where searchField will be for example start_date and the data type is DateTime, delimiter is " (tried with nothing as well) and searchString will be 01-Jan-2009 (tried with 01/01/2009 as well) and items is an IQueryable from LinqToSql. Is there a way of specifying the data type in a dynamic where, or is there a better approach. It is currently already using some reflection to work out what type of delimiter is required.

    Read the article

  • Jointure in linq with a regular expression

    - by Graveen
    I'm actually using a join in linqtosql (via dblinq). I'm trying to include a regular expression in the join part of the linq query. from i in collectiona join j in collectionb on Regex.IsMatch(i.name, j.jokered_name) equals true (...) I agree i can push the RegExp check in the where part of the linq query, but i was wondering if it is possible in the join part ? The above code wants an "i equals j" code structure. One thing i think to perform is overriding Equals() which 'll contains the RegEx.IsMatch() stuff and put a simple i equals j in the join part. Any suggestions about my problem ?

    Read the article

  • Dynamic query to immediate execute?

    - by Curtis White
    I am using the MSDN Dynamic linq to sql package. It allows using strings for queries. But, the returned type is an IQueryable and not an IQueryable<T>. I do not have the ToList() method. How can I this immediate execute without manually enumerating over the IQueryable? My goal is to databind to the Selecting event on a linqtosql datasource and that throws a datacontext disposed exception. I can set the query as the Datasource on a gridview though. Any help greatly appreciated! Thanks. The dynamic linq to sql is the one from the samples that comes with visual studio.

    Read the article

  • How to: Display multiple related classes in an ASP.NET GridView ?

    - by kversch
    I would like to display students and their grades with a GridView and LinqToSQL like this: assignment1 assignment2 Student 1 55 89 Student 2 87 56 Student 3 92 34 I found this topic but it doesn't answer my question: http://forums.asp.net/t/1557987.aspx I have a many-to-many relationship between students and assignments called "grades". The grade for the assignment is stored in that table in a "gradeNumber" column. I would also like to specify which assignments should be displayed in the grid. Btw, my LINQ entities are extended to allow me to write/get studentx.Assignments or assignmentx.Students.

    Read the article

  • PLINQO Not Naming Entities Correctly

    - by Clever Human
    I have my CSP file set up to use TableNaming and EntityNaming as Singular: <TableNaming>Singular</TableNaming> <EntityNaming>Singular</EntityNaming> Yet the generated entities are plural. For instance, I have a table called Companies. The generated name is "Companies" I expected "Company" (like LinqToSql did -- I am upgrading a project.) I have a table named EntityStorageItems (no relation to these entities.) The generated name is "EntityStorageItems" I expected the entity name to be "EntityStorageItem" IOW, it is creating plural names. And I need them to be singular (to work with existing code.) Am I doing something wrong?

    Read the article

  • One-to-many relationship related to many tables

    - by Andrey
    I have a scenario where: there are two (or more) tables that represent independent items. lets say Users and Companies Both of these tables need addresses stored. Each one can have one or more address In a normal 1 to many scenario Addresses table woudl just have a UserId or a CompanyId creating a normal 1 to many relationship. In this case i have a few approaches i can think of the Addresses table could have both a UserId and a CompanyId and only one would be used for each record. 2 keys could be used ObjectId and ObjectType So Object id would have a UserId or a CompanyId, and ObjectType woudl be User or Company Create an ObjectTable and add ObjectId to Users and Companies. Addresses would then have an OjbectId I do not really like any of these solutions. i am wondering what is the best approach here. On another note i will most likely user linqtosql for my data access layer.

    Read the article

  • Linq to Sql GroupJoin Paging oddity

    - by OllyA
    I have noticed a strange Sql Translation in a LinqToSql Query I was trying to optimise. If I execute the following Recipients.GroupJoin( RecipientAttributes, x => x.Recipient_Id, y => y.Recipient_Id, (x,y) => new {Recipient = x, Attributes = y}) .Skip(1) .Take(1000) It executes in a single query as expected. However Recipients.GroupJoin( RecipientAttributes, x => x.Recipient_Id, y => y.Recipient_Id, (x,y) => new {Recipient = x, Attributes = y}) .Skip(0) .Take(1000) executes in a separate query for each Attributes selection. Removing the Skip(0) makes no difference either. Can anyone explain this and is there something I can do to get the first page query executing in a single sql statement?

    Read the article

  • Why do I get "Invalid Column Name" errors in EF4?

    - by camainc
    I am trying to learn Entity Framework 4.0. Disclaimer 1: I am brand new to Entity Framework. I have successfully used LinqToSQL. Disclaimer 2: I am really a VB.Net programmer, so the problem could be in the C# code. Given this code snippet: public int Login(string UserName, string Password) { return _dbContext.Memberships .Where(membership => membership.UserName.ToLower() == UserName.ToLower() && membership.Password == Password) .SingleOrDefault().PrimaryKey; } Why do you suppose I get "Invalid column name" errors? {"Invalid column name 'UserName'.\r\nInvalid column name 'Password'.\r\nInvalid column name 'UserName'.\r\nInvalid column name 'Password'."} Those column names are spelled and cased correctly. I also checked the generated code for the entity in question, and those columns are properties in the entity. The intellisense and code completion also puts the column names into the expression just as they are here. I am stumped by this. Any help would be much appreciated. https://docs.google.com/leaf?id=0B-xLbzoqGvXvNjBmZmNjNDAtY2RhNC00NDA2LWIxNzMtYjhjNTYxMDIyZmZl&hl=en

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >