ADO.NET :: Moving Records Up And Down With Linq?
Dec 28, 2010I need Moving records up and down with Linq
View 1 RepliesI need Moving records up and down with Linq
View 1 RepliesI'm trying to build a small back-end page for adding business references to 'portfolio' front-end page.
I chose the GridView control for displaying current items, and am currently working on positioning code(display order) with button fields up/down.
The up/down button code works fine until the GridView is sorted by clicking the header field, then it breaks.
Here is the relevant code:
[Code]....
I have a data table I need to convert to XML. I know I can use datable.WriteXML but I need to rename the elements as the column names coming from the Oracle db are ugly. I found this snippet somewhere:
[code]....
It looks like what I want but when I paste it in my code it shows an error on select Cannont convert lambda expression to type 'string' because it is not a delegate type.
I am new to linq and for that matter to C# (done a lot more vb). I am going to read the books but I need to get this done pretty quick for a project.
Post table
int_PostId int Unchecked
int_TemplateId int Checked
int_OrganizationId int Checked
int_SortOrder int Checked
int_PostTypeId int Checked
int_PostStatusId int Checked
int_Hits bigint Checked
int_CreatedBy int Checked
dtm_CreatedDate datetime Checked
int_ModifiedBy int Checked
dtm_ModifiedDate datetime Checked
29
1
23
1
2
4
NULL
41
2010-09-09 12:24:38.970
41
2010-09-09 12:26:50.063
30
1
23
1
2
4
NULL
41
2010-09-09 12:27:22.817
NULL
NULL
31
1
23
1
1
3
NULL
41
2010-09-09 12:51:17.933
NULL
NULL
32
1
23
NULL
1
3
NULL
41
2010-09-09 12:58:32.650
NULL
NULL
33
1
23
1
2
3
NULL
41
2010-09-09 13:23:51.757
NULL
NULL
34
1
23
1
2
3
NULL
41
2010-09-09 13:24:34.517
NULL
NULL
35
1
26
1
2
3
NULL
41
2010-09-14 17:34:35.517
41
2010-09-14 17:37:41.857
36
1
26
145
2
5
NULL
41
2010-09-14 17:43:04.423
41
2010-09-14 17:44:40.167
Post Meta Table
int_MetaId int Unchecked
vcr_MetaKey nvarchar(200) Checked
vcr_MetaValue nvarchar(200) Checked
int_PostId int Checked
bit_IsPostType bit Checked
int_CreatedBy int Checked
dtm_CreatedDate datetime Checked
int_ModifiedBy int Checked
dtm_ModifiedDate datetime Checked
57
chkEng
true
6
NULL
36
2010-10-12 07:59:05.357
NULL
NULL
58
chkdar
false
6
NULL
36
2010-10-12 07:59:05.357
NULL
NULL
59
chkpsh
false
6
NULL
36
2010-10-12 07:59:05.357
NULL
NULL
60
Publish Date
08/22/2010
6
True
42
2010-10-12 07:59:05.357
NULL
NULL
61
Thumbnail Image
6
True
42
2010-10-12 07:59:05.357
NULL
NULL
62
Featured Image
6
True
42
2010-10-12 07:59:05.357
NULL
NULL
63
Source
6
True
42
2010-10-12 07:59:05.357
NULL
NULL
71
chkEng
true
8
NULL
42
2010-10-12 08:01:26.900
NULL
NULL
72
chkdar
false
8
NULL
42
2010-10-12 08:01:26.900
NULL
NULL
73
chkpsh
false
8
NULL
42
2010-10-12 08:01:26.900
NULL
NULL
74
Publish Date
08/22/2010
8
True
42
2010-10-12 08:01:26.900
NULL
NULL
75
Source
8
True
42
2010-10-12 08:01:26.900
NULL
NULL
76
Thumbnail Image
8
True
42
2010-10-12 08:01:26.900
NULL
NULL
77
Featured Image
8
True
42
2010-10-12 08:01:26.900
NULL
NULL
78
chkEng
true
7
NULL
43
2010-10-12 08:02:08.417
NULL
NULL
79
chkdar
false
7
NULL
43
2010-10-12 08:02:08.417
NULL
NULL
80
chkpsh
false
7
NULL
43
2010-10-12 08:02:08.417
NULL
NULL
81
Publish Date
7
True
43
2010-10-12 08:02:08.417
NULL
NULL
i included the table and its data as it would be impossible without that to understand. this is the meta scenario as you may notice that this was the query i wrote before when i was not checking the publish date
var postsidebar = from post in postrepository.GetAllPosts()
join pstmt in postrepository.GetAllPostMetas()
on post.int_PostId equals pstmt.int_PostId
where (post.int_PostTypeId == 4 && post.int_PostStatusId == 2 && post.int_OrganizationId == layoutrep.GetSidebarDetailById(SidebarDetailsId).int_OrganizationId)
&& (pstmt.vcr_MetaKey.Contains(filter) && pstmt.vcr_MetaValue.Contains("true"))
select post
how would i goint incoperate check for publish date in the query above( i want to bring all the records whose publish date is greater then todays date)
I need to find the count of records between the first and last day of the current month.I am very new to linq and having doubts in getting the count, below is the code i have written.
[code]....
I have two DataSet were mention below DataSet1 & DataSet2. DataSet1 records are already in User Database table. I would like to insert the DataSet2 records to User table, Before going to insert the Dataset2, I am trying to check the duplicate records in DataSet2 Compare with DataSet1. How to identify the duplicate records in DataSet2 using LINQ. I want to Get the List of Duplicate record set. Or Return the True Or False.
Note: In User table SiteId and UserName is Combinational primary key Records.
My project includes a grid view with some updtable fields, some fields throw an error on update and some do not and it does not really make sense. WORK_STATION_ID does not cause an error, ROOM _ID cause an error, both are int? (I am using c#) and for update I use the code liste below.
[Code]....
[Code]....
I am using Linq to SQL. I have a table with a uniqueidentifyer column.
I need to insert 1000 records, each with all the same values except for the uniqueid field.
I know the syntax to insert a single record for example where dc is a DataContext():
[Code]....
Does anyone know how if there is a way, other than looping 1000 times, to tell SQL to insert 1000 records generating different unique ids but assign the constant values to the other columns?
in which after changing the appropriate value if user clicks on "Save and Next" or "Save and Previous"
then by saving that particular record I have to move to the next or previous record respectively.
So in that record should be saved as well as it should display another record also in the screen.
I had done this problem with the help of normal SQL query in Asp.Net but in that case I have to solve it using LINQ.
I worked with LINQ to SQL to insert and delete the data,but i want to use LINQ TO ENTITY to insert the data but i know LINQ to ENTITY is used for querying the database.I have searched the code for inserting records but i dint get any.
View 7 Repliesi have an array with id numbers (of the products) in it.
Like for example:
string[] productIds = { "5", "12", "2", "2" };
Now i want to select only the records that only have the id numbers from the array, is it possible?
i have a link query that retrun all the records that have their status = 'completed' ordered by their ids, but i want to return only three records not all the records
View 2 Replieshope to delete all records in DBPrograms, is the following code correct?
DBContext db = DBContext(PublicDBPar.ConnectionString);
db.DBPrograms.DeleteAllOnSubmit(db.DBPrograms);
db.SubmitChanges();
I am facing an intresting problem now with entity framework. if i did a count of the some table with linq statement its give some count and it is not matching with my normal sql query count. my sql query returning count of all the records in that table where as linq query returns some count which is less than sql count. is this a problem with my edmx or table navigation properties..i do have some 5 to 6 child tables inside this table with foreignkey relation. will it do a join on each child table and returns only those records. I am very much confused and don't know how to slove this.
View 9 RepliesI am inserting records using stored procedures in LINQ to SQL in MVC.but i don't know the proper way.
View 1 Replies in this scenario if if i bring all the records at once from this query
var pages=_db.Pages;
and then i will process according to some scenario
pages.Where(m => m.int_PostStatusId == 2)
pages.Where(m => m.int_PostStatusId == 3) and so on
is it really saving some processing time? or not (what really to do ?)
I am having trouble with duplicate records. I tested .distinct() in several areas and nothing helps.
I got the search criteria from the PreviousPage. I then used this criteria to search QueryA.
I did a search using QueryA. I took the results, and put the IDs into an array.
I then did a search using QueryB, that matched the IDs in the array. QueryB is used for the ListView and to page records.
Using test records. QueryA results = 2 records. The array.length = 2. QueryB results = 3. ?
What am I doing wrong ?
Some of my Code:
myResults = (from r in QueryA
select r.ID).Distinct().ToArray();
totalrecords = myResults.Length; // = 2
using (ToHealthEN n = new ToHealthEN())
{
[Code]...
Is there anyway I can access the individual attributes of a profile record?
I want to access the address fields of a user stored in my aspnet_profiles table.
I have a table 'articles' where all the articles are stored and I want to create a search engine for my website.
user types the keywords in the search engine and what code i should use to search the records in my database?
how to insert records in multiple table using with foreign key with linq to sql?
View 2 Repliesthis is my code
[code]....
basically, the InstellingGegevens table gest filled in by some procedure from another server.
the thing i then need to do is check if there are new records in this table, and fill in the new ones in Instellingens.
this code runs for like 4 minutes on 15k records. how do I optimize it? or is the only way a Stored Procedure?
this code runs in a timer, running every 6h. IF a stored procedure is best, how to I use that in a timer?
[code]....
My team working asp.net File manage project. In our project we need to export database contents to csv formats
The Database table contains 6 fields. We are using LINQ.
I've got a linq to sql query that pulls data from 2 different tables and contains an or statement:
[Code]....
The problem I've got is that some queries match both sides of the or statement so it returns the same record twice.
How can I eliminate these duplicates quickly and easily?
can we wirte linq query to select few records based on the from and to records..
View 3 RepliesI am using LINQ Expression to insert records in SQL Table. My Table dosen's have any Primary Key Field. Whenever I Am trying to Insert Records in Table using LINQ Expression, this always occurs an Error that 'the Table You are using to insert Dosen't Have Any Primary Key Field.
How I Will Insert Records Without Having Primary Key ?