 |
|
 |
it is nice example!! quite enjoy after reading ?
How about the update? in compact framework using LINQ?
normal LINQ with datacontext to perform update/insert as
NorthwindDataContext db = new NorthwindDataContext(); var newCustomer = new Customer { CustomerID = "MCSFT", CompanyName = "Microsoft", ContactName = "John Doe", ContactTitle = "Sales Manager", Address = "1 Microsoft Way", City = "Redmond", Region = "WA", PostalCode = "98052", Country = "USA", Phone = "(425) 555-1234", Fax = null }; db.Customers.InsertOnSubmit(newCustomer); db.SubmitChanges();
but in compact framework 3.5, datacontext for database is not applicable.
Any good way to implement "update/insert" using linq over dataset on windows mobile?
Thank you
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi What do you mean? Update DB? something Like Linq to SQL or in memory updates?
Oleg Levin .NET Development Manager
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Hope you still get mail from this article.
I have a question for you? Hope its all right.
I have made a similar solution but i have problem formatting the columns. I read data from an xml file into a dataset and then i do a search from my ds with linq. Then i set the result from the search as the datasourc on my grid. Then i want to resize the columns in the grid. But thats when i run out of luck.
So when i searched for that i found your code.
I need to set the column width in the grid. I know im supposed to use the DataGridTableStyle but i guess i do something wrong with the mappingname against the linq result.
this is my code: Dim x As List(Of Books) Dim s As String = "*" & UCase(txtSearch.Text) & "*"
x = (From b In ds.Book Join w In ds.Writer On w.idWriter Equals b.idWriter _ Where UCase(b.Title) Like s Or UCase(w.LastName) Like s Or UCase(w.FirstName) Like s _ Order By b.Title, w.LastName _ Select New Books(b.Title, w.FirstName, w.LastName, b.Rating, b.Year, b.Price)).ToList
Dim arrColumnNames(4) As String
arrColumnNames(0) = "Titel" arrColumnNames(1) = "Författare" arrColumnNames(2) = "Betyg" arrColumnNames(3) = "Pris" arrColumnNames(4) = "Utg.År"
Dim BookStyle As New DataGridTableStyle BookStyle.MappingName = "books"
Dim i As Integer = 0 For i = 0 To UBound(arrColumnNames) Dim myDataCol As New DataGridTextBoxColumn myDataCol.HeaderText = arrColumnNames(i) myDataCol.MappingName = _result.Tables("books").Columns(i).ColumnName myDataCol.Width = Int(200) BookStyle.GridColumnStyles.Add(myDataCol) myDataCol = Nothing Next dgBooks.TableStyles.Clear() dgBooks.TableStyles.Add(BookStyle) dgBooks.datasource = x
Any idea what im doing wrong?
Thanks /Magnus
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi It's difficult to see problem in this piece of code but my first remark: you write:BookStyle.MappingName == "books" but your entity is "Books" try change to BookStyle.MappingName == "Books" If you can, give me please your source code i will try to help you (c# my 1st priority)
Oleg Levin .NET Development Manager
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, I am trying to compile your project using Orcas beta2, but got following errors:
Error 1 'LinqDemo.EntitiesDS.CountriesDataTable' does not contain a definition for 'AsEnumerable' and no extension method 'AsEnumerable' accepting a first argument of type 'LinqDemo.EntitiesDS.CountriesDataTable' could be found (are you missing a using directive or an assembly reference?) D:\Codes\LinqDemo_src\LinqDemo\MainForm.cs 61 35 LinqDemo
Do I need to configure something in Orcas beta2 to make it work? Thanks.
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
Hi. To solve this problem please add Reference to your project: system.data.DataSetExtensions
Oleg Levin .NET Developer/Group Leader
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
|
 |
|
 |
Hi Oleg,
I read your article and I would like your help I am having trouble writing my first mobile application with Compact Framework and SQL server. Can you give me some sample mobile code for a small application so that I can see how it works.
Many thanks,
Pamela 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi Oleg,
Thank you for replying and the answer is yes to your question. Over the weekend I wrote my first web service and I would love if you could help me solve some problems.
1. How can I make the mouse cursor look busy ? 2. How can I resize the datagrid fields ? 3. Can I transfer files via web service ?
thanks again,
Pam
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I am answering to your questions:
1. Cursor.Current = Cursors.Wait 2.Resize datagrid columns VB.NET sample: 'Create new Table Style.
Dim ts As New DataGridTableStyle() ts.MappingName = "Employees" DataGrid1.TableStyles.Clear() DataGrid1.TableStyles.Add(ts) ' Assign New Width to DataGrid column.
DataGrid1.TableStyles("Employees").GridColumnStyles("Title").Width = newwidth 3.Transfer files via web service C#: [WebMethod] public byte[] GetFile(string filename) { BinaryReader binReader = new BinaryReader(File.Open(Server.MapPath(filename), FileMode.Open, FileAccess.Read)); binReader.BaseStream.Position = 0; byte[] binFile = binReader.ReadBytes(Convert.ToInt32(binReader.BaseStream.Length)); binReader.Close(); return binFile; }
[WebMethod] public void PutFile(byte[] buffer, string filename) { BinaryWriter binWriter = new BinaryWriter(File.Open(Server.MapPath(filename), FileMode.CreateNew, FileAccess.ReadWrite)); binWriter.Write(buffer); binWriter.Close(); }
Some useful samples here: http://samples.gotdotnet.com/quickstart/CompactFramework/[^]
Oleg Levin .NET Developer/Group Leader
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
Wow, thanks Oleg
I feel that at last I am getting somewhere
I hope that you don't mind me asking you so many questions 
Here are some more,
1. Is it possible to connect the Emulator (Pocket PC / Windows CE) to the activesync?
2. concerning the webservice
I have a folder c:\webTest which contains my webservice and a subfolder
c:\webTest\images containing some images. When I try to transfer files from the images folder to the PDA I get the following error: " server was unable to process request.---> c:\webTest\images\Jenny.jpg is not a valid virtual path "
Thanks again
Pamela
-- modified at 8:12 Wednesday 18th July, 2007
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | LINQ  gagliapas | 14:43 19 Jun '07 |
|
 |
Besides improvements of code readability, is there any improvement in terms of query performances? I am evaluating the porting of a solution developed with ADO, do you suggest it?
Thanks,
Pas
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi. May be better to wait for final release and after that make discussions about performance. Thanks.
Oleg Levin .NET Developer
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | nice  Sacha Barber | 23:37 14 Jun '07 |
|
|
 |
|
|
 |
 | Thanks  merlin981 | 6:21 14 Jun '07 |
|
|
 |