Solved

Mysql with Linq 2 Entities

Posted on 2010-09-02
3
388 Views
Last Modified: 2012-05-10
I want to recieve all rows from a mysql table and got problems immedietly when adding a "created" field to the model. The created-field is a TIMESTAMP in mysql and appears to be a DateTimeOffset in the model. This give me bug-like-problem when reading the data. How am I possible to cast this field to a string or something?

0
Comment
Question by:dingir
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Ashok earned 500 total points
ID: 33585796
public static string TimestampToString(this System.Data.Linq.Binary binary)  
{
  byte[] binarybytes = binary.ToArray();  
  string result = "";  
  foreach (byte b in binarybytes)  
  {
    result += b.ToString() + "|";  
  }
  result = result.Substring(0, result.Length - 1);
  return result;  
}  

>>>>> There is one more >>>>  public static System.Data.Linq.Binary StringToTimestamp(this string s)

Read complete articel @ http://geekswithblogs.net/AndrewSiemer/archive/2008/02/11/converting-a-system.data.linq.binary-or-timestamp-to-a-string-and-back.aspx

HTH
Ashok
0
 
LVL 1

Author Comment

by:dingir
ID: 33593792
Wow that was a hack..

However i seemed to fix it just by adjust connection string.. i will check it today and leave a  feedback
0
 
LVL 1

Author Closing Comment

by:dingir
ID: 33698785
Not really a solution but maybe it help someone else,
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Login 17 51
MediaHelp 4 23
FTP file download using c# 3 23
RegEx with optional part 4 26
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question