In my application I'm pulling back a user's "feed". This contains all of that user's activities, events, friend requests from other users, etc. When I pull back the feed I'm calling various functions to filter the request along the way.
var userFeed = GetFeed(db); // Query to pull back all data userFeed = FilterByUser(userFeed, user, db); // Filter for the user userFeed = SortFeed(userFeed, page, sortBy, typeName); // Sort it
The data that is returned is exactly what I need, however when I look at a SQL Profile Trace I can see that the query that is getting this data does not filter it at the database level and instead is selecting ALL data in the table(s).
This query does not execute until I iterate through the results on my view. All of these functions return an IEnumerable object.
I was under the impression that LINQ would take all of my filters and form one query to pull back the data I want instead of pulling back all the data and then filtering it on the server.
I have placed a textbox, dropdownlist and command button in a section of my master page. The textbox, named txtsearch, will be used to input a search string. The dropdownlist, named ddlsearch, will be used to specify in which field to search in the table, either part name or NSN.
Questions:
What VB code do I use to save the value entered into txtsearch as a search string? How do I pass that value to my entitydatasource? How do I tell entitydatasource to search in either the part name or NSN field based on the value of ddlsearch?
I have a datamodel with a couple of tables. One of my tables have about 40 fields (I know that is a lot, but we have to keep the structure in place as we are upgrading a classic ASP project to MVC). Some of my Actions only updates 1 or 2 fields in my table.
Is there a way to create Entities, for instance, that only contains the contact details of the client table, and not any other details, and then another entity that contains only the address details. I don't want to submit the entire row when I only update telephone details, or the client's picture.
I am doing this in my stored proc. Creating a temp table. Dumping the select results into the temp table and then select the info where the search string is based on the status name info.
because of the temp table, it is taking long to excecute. How can I get rid of the temp table and still seach based on the CurrentStatusName
Create proc [dbo].[usp_GetRequestsInfoOnSearchString] ( @SearchString varchar(100) ) as Create TABLE #Request( [RequestId] [int] NULL, [RequestDate] [datetime] NULL, [RequestText] [varchar](500) NULL, [CurrentStatusId] [int] NULL, [RiskLevelId] [int] NULL ) INSERT into #Request ([RequestId] , [RequestDate] , [RequestText] , [CurrentStatusId] , [RiskLevelId] ) SELECT [RequestId] ,[RequestDate] ,[RequestText] ,CurrentStatusName = dbo.udf_GetRequestStatusName(CurrentStatusId) ,[RiskLevelId] FROM [dbo].[Request] select [RequestId] as [Request Id] ,[RequestDate] as [Request Date] ,[RequestText] as [Request Text] ,[CurrentStatusName] as [Current Status Name] from #Request WHERE ([CurrentStatusName] like @SearchString OR len(@SearchString)= 0 OR @SearchString is null)
As I tested SQL temp table drops every time when sql connection from ASP.NET is closed/open. Is this only way using it, or it can be used depends on ASP.NET session as well? I'd need to access temp table from more separate selects on more different pages on the web site, if it is possible.
How to use Stored Procedures with Linq to Entities? I prefer an example with input and output The videos on asp.net only show how to do this with Linq to SQL.
SELECT * FROM MessageAlerts AS A LEFT OUTER JOIN Contacts AS C ON A.ContactId = C.Id LEFT OUTER JOIN Users AS U ON A.UserId = U.Id INNER JOIN Businesses AS B ON B.Id = C.BusinessId OR B.UserId = U.Id
how to do this : ON B.Id = C.BusinessId OR B.UserId = U.Id with linq in entity framework.
Suppose I have a temporary table (Shown below). The table is defined and populated in my stored procedure. After it is populated, I need to go through every row in the table. Here is what I need to do :
Check if Amount2 > Amount1 If Amount2 > Amount1 then set Amount1 = Amount2
It feels a little akward for me to use the temp table.
I can join with a regular SQL table fine but this won't work:
SELECT normalTbl.*, tmp.fld1 FROM normalTbl LEFT JOIN #Temp tmp ON tmp.joinID = normalTbl.joinID
All tmp.fld1 values are shown as NULL even though fld1 contains valid values and the joinID matches the normalTbl (when I call SELECT * from #Temp). If I do the same exact thing with a regular table, fld1 shows the correct value. What am I doing wrong?
WHY are all the examples on this site linq to SQL? Did ms not themselves announce dropping support for l2SQL over a year ago? i really don't get it. Examples are great.. but really not helping me since i've gone ahead and listened to MS. And can someone at MS clarify what the position is for linq 2 SQL.. Is it supported? Recommended? What the hell.
I am trying to learn LINQ to entities, and am working out how to best structure my BLL layer. I have generated the entity model and have created a generic repository in my DAL that returns results as IList<T>. I initially created the BLL to also return
results as IList<T>:
public IList<DAL.Customer> SelectAll() { [code]...
Now I am working on the aspx page, and I can create an ObjectDataSource and configure it to use my BLL, but since I am returning IList, I can't sort since I am not using a DataView. I have seen some articles on the web for converting IList to DataView, but that seems like a lot of overhead for every query.My goal is to keep a clean separation between layers without making things overly complicated. I would like to know how others have done this, or maybe a link to a good tutorial that shows how to structure all three layers.
i would like to retrieve data from two table, how can i create a temp table and then insert data from two different table.and then use the temp table to join other table in stored procedure.if i want to select same data from two table, how can i select all distinct data from two table into temp table
I want to create a temp table to store data in a stored procedure and then then retrive it from the code. I need to save the data in the begining before it is deleted.And then after the inserts are done I want to update the tblcontactlist by referring to the temp table.
I'm trying to call a linked server, SS2000 that has NText field and instert that data into an nvarchar(120) field on SS2008.
If I execute the SPROC from SS2008 Management Studio, it works fine. If I try to call the SPROC from my ASP.NET 3.5 web application, I don't get any errors, but the data doesn't get updated.
I'm using the following SPROC: CREATE PROCEDURE [dbo].[usp_UpdateMilestoneDescription] @UID int AS BEGIN
I am building a web application in asp.Net 4.0 and entity framework. I am trying to retrieve a list of products based on a collection of id's. I first gather all the id's in a collection and then pass it to the linq query. I am trying to get a functionality similar to the IN clause in SQL. The problem seems to be with the Contains() method in the Linq to entities query. Here is my Linq code:
[Code]....
I got the above Linq to entities method from here: [URL]
I have a message table that self joins to itself where Message.ID == Message.Parent. So I have 1 Message with several ChildMessages. This is set up nicely with a Navigation property.
The code is currently:
var message = from m in soe.Messages.Include("ChildMessages") where m.ID == id && m.IsActive select m; return message.FirstOrDefault();
What I really want is to only return 1 Message (that is equal to a particular ID and isActive) with all of its Active ChildMessages and I want to do it in one call to the database.
i have a table with a field name called 'Firstname' and another field name called 'Lastname'. I would want to have a single column in my GridView which show Fullname and then the firstname and lastname are showed here under an alias. Also, i am binding my GridView using LINQ.So is there a way to create aliaswith LINQ and to use these with GridView ? Would love to have an hint about how i can realize this task.
I use the Entity Framework and Linq to Entities with MVC 2.0. When use the DropDownListFor from Html helpers to populate a dropdown that contains an ID from a foreign object, I post the form data but I canīt set the correct relation. Using the debug, I can see the ID retrieved from dropdown at my returned foreign object ID, but I think that I not use the association correctly.
have already used the latest technology in a professional manner. NETBasically I have two tables related 1 to 1:the Users table and the table ProfiloPersonale is the key to the Users table that this table are ProfiloPersonale iduser and type uniqueidentifier and diagram sql server 2008 I can clearly see the report, I also did a test to insert a record in the users table ( fictional) directly from sql server and everything works.With LINQ to Entities does not work:The entities 'LEntities.Users' part of the eport 'ProfiloPersonale'.Found 'ProfiloPersonale' related to 0.Expected 1 'ProfiloPersonale'Of course what I am doing is to first create the user and then create their profile in the db, taking the id of the registered
I have a view on my database and I am trying to add a new record using the AddTo method but it is not working. I noticed that LinqToEntities is creating the insert statement like this
Insert into (select field1, field2 from my_view) (field1, field2) values (value1, value2)
Is it possible to make LinqToEntities create the insert statement like the one below ?
Insert into my_view (field1, field2) values (value1, value2)