Click here to Skip to main content
15,907,233 members
Home / Discussions / C#
   

C#

 
AnswerRe: Q&A widget please. Pin
Shady George12-Apr-14 11:28
Shady George12-Apr-14 11:28 
GeneralRe: Q&A widget please. Pin
Richard Andrew x6412-Apr-14 15:10
professionalRichard Andrew x6412-Apr-14 15:10 
GeneralRe: Q&A widget please. Pin
Shady George12-Apr-14 17:40
Shady George12-Apr-14 17:40 
AnswerRe: Q&A widget please. Pin
OriginalGriff13-Apr-14 2:42
mveOriginalGriff13-Apr-14 2:42 
AnswerRe: Q&A widget please. Pin
Jay Nardev13-Apr-14 7:44
Jay Nardev13-Apr-14 7:44 
QuestionI found This Error When I run My programe The data reader is incompatible with the specified 'DBLaxmiTatkalModel.TblAttendence'. A member of the type, 'AttendenceId', does not have a... Pin
Šangeet Šhah11-Apr-14 18:10
professionalŠangeet Šhah11-Apr-14 18:10 
AnswerRe: I found This Error When I run My programe The data reader is incompatible with the specified 'DBLaxmiTatkalModel.TblAttendence'. A member of the type, 'AttendenceId', does not have a... Pin
Mycroft Holmes11-Apr-14 22:55
professionalMycroft Holmes11-Apr-14 22:55 
Questionif a real number has two dots in it it must display error that it is not a real number Pin
Member 1074041211-Apr-14 15:09
Member 1074041211-Apr-14 15:09 
GeneralRe: if a real number has two dots in it it must display error that it is not a real number Pin
PIEBALDconsult11-Apr-14 15:25
mvePIEBALDconsult11-Apr-14 15:25 
Questionthuật toán k-mean Pin
Member 1074281911-Apr-14 8:03
Member 1074281911-Apr-14 8:03 
SuggestionRe: thuật toán k-mean Pin
Richard Deeming11-Apr-14 8:16
mveRichard Deeming11-Apr-14 8:16 
QuestionError msg conveying that a number is invalid because of Two dots within a real number in c# Pin
Member 1074041211-Apr-14 7:00
Member 1074041211-Apr-14 7:00 
AnswerRe: Error msg conveying that a number is invalid because of Two dots within a real number in c# Pin
Dave Kreskowiak11-Apr-14 7:03
mveDave Kreskowiak11-Apr-14 7:03 
GeneralRe: Error msg conveying that a number is invalid because of Two dots within a real number in c# Pin
phil.o11-Apr-14 7:18
professionalphil.o11-Apr-14 7:18 
GeneralRe: Error msg conveying that a number is invalid because of Two dots within a real number in c# Pin
Eddy Vluggen11-Apr-14 7:48
professionalEddy Vluggen11-Apr-14 7:48 
QuestionOpen file image with inform C# Pin
Member 1039071511-Apr-14 6:38
Member 1039071511-Apr-14 6:38 
AnswerRe: Open file image with inform C# Pin
Dave Kreskowiak11-Apr-14 7:00
mveDave Kreskowiak11-Apr-14 7:00 
GeneralRe: Open file image with inform C# Pin
Member 1039071511-Apr-14 8:07
Member 1039071511-Apr-14 8:07 
GeneralRe: Open file image with inform C# Pin
Dave Kreskowiak11-Apr-14 9:09
mveDave Kreskowiak11-Apr-14 9:09 
Questiondownload a file from google drive Pin
BODEMPUDI_CHOWDARY11-Apr-14 4:38
BODEMPUDI_CHOWDARY11-Apr-14 4:38 
AnswerRe: download a file from google drive Pin
Richard MacCutchan11-Apr-14 4:56
mveRichard MacCutchan11-Apr-14 4:56 
AnswerRe: download a file from google drive Pin
Mycroft Holmes11-Apr-14 13:45
professionalMycroft Holmes11-Apr-14 13:45 
QuestionStoring deserialized data into SQL Server Ce using Entity Framework code first Pin
sifi mohamed amine10-Apr-14 23:12
sifi mohamed amine10-Apr-14 23:12 
I need to add deserialized data from xml file to the model in Entity Framework cod efirst in order to generate my database in SQL Server CE.
The problem was that I have two tables , the first was done without problems but when I added the second model I got an exception :

{"Exception has been thrown by the type initializer for 'DAL.MyModel.InformationContext."}

I will be so thankful if someone could help me .

Here my source code in the Program.cs:

C#
//Storing balance data into the database
            using (InformationContext db = new InformationContext())
            {
                db.Balances.Add(new Balance_Model()
                {
                    EuroBookingBalance = Bal.ElementAt(0).EuroBookingBalance,
                    Id = Bal.ElementAt(0).Id,
                    ABI = Bal.ElementAt(0).Account.ABI,
                    BBAN = Bal.ElementAt(0).Account.BBAN,
                    CIN = Bal.ElementAt(0).Account.CIN,
                    Currency = Bal.ElementAt(0).Account.Currency,
                    Description = Bal.ElementAt(0).Account.Description,
                    Number = Bal.ElementAt(0).Account.Number,
                    AccountId = Bal.ElementAt(0).Account.Id,
                    Date = Bal.ElementAt(0).Date.ToString(),
                    AccountHolder = Bal.ElementAt(0).Account.AccountHolder,
                    CAB = Bal.ElementAt(0).Account.CAB,
                    CurrencyBookingBalance = Bal.ElementAt(0).CurrencyBookingBalance
                    
                });

                db.Transactions.Add(new Transaction_Model()
                {
                    ABI = tra.ElementAt(0).Account.ABI,
                    AccountDescription = tra.ElementAt(0).Account.Description.ToString(),
                    Amount = tra.ElementAt(0).Amount,
                    TransactionDate = tra.ElementAt(0).TransactionDate.ToString(),
                    AdditionalDescription = tra.ElementAt(0).AdditionalDescription,
                    AccountHolder = tra.ElementAt(0).Account.AccountHolder,
                    CAB = tra.ElementAt(0).Account.CAB,
                    Currency = tra.ElementAt(0).Currency,
                    Description = tra.ElementAt(0).Description,
                    Id = tra.ElementAt(0).Id,
                    Number = tra.ElementAt(0).Account.Number.ToString(),
                    ValueDate = tra.ElementAt(0).ValueDate.ToString(),
                    AbiReason = tra.ElementAt(0).AbiReason.ToString()
                });
                db.SaveChanges();


Here my Initializer class ;
C#
class DbInitializer : DropCreateDatabaseAlways<InformationContext>
       {
           protected override void Seed(InformationContext context)
           {
               string pathXml = @"C:\Users\Mohamed amine sifi\Desktop\balancess.xml";
               // Deserialization of Balance data
               Balances Bal = new Balances();
               XmlSerializer serializer = new XmlSerializer(typeof(Balances), null, null, new XmlRootAttribute("Balances"), "urn:Cedac:WebContoc:Balances:v1");
               StreamReader reader = new StreamReader(pathXml);
               var xmlReader = XmlReader.Create(reader.BaseStream);
               object deserialized = (Balances)serializer.Deserialize(xmlReader);
               Bal = (Balances)deserialized;

               string pathXmlt = @"C:\Users\Mohamed amine sifi\Desktop\transactions.xml";
               TransactionsList tra = new TransactionsList();
               XmlSerializer serializert = new XmlSerializer(typeof(TransactionsList), null, null, new XmlRootAttribute("Transactions"), "urn:Cedac:WebContoc:Transactions:v1");
               StreamReader readert = new StreamReader(pathXmlt);
               var xmlReadert = XmlReader.Create(readert.BaseStream);
               object deserializedt = (TransactionsList)serializer.Deserialize(xmlReader);
               tra = (TransactionsList)deserializedt;

               context.Balances.Add(new Balance_Model()
               {
                   EuroBookingBalance = Bal.ElementAt(1).EuroBookingBalance,
                   Id = Bal.ElementAt(1).Id,
                   ABI = Bal.ElementAt(1).Account.ABI,
                   BBAN = Bal.ElementAt(1).Account.BBAN,
                   CIN = Bal.ElementAt(1).Account.CIN,
                   Currency = Bal.ElementAt(1).Account.Currency,
                   Description = Bal.ElementAt(1).Account.Description,
                   Number = Bal.ElementAt(1).Account.Number,
                   AccountId = Bal.ElementAt(1).Account.Id,
                   Date = Bal.ElementAt(1).Date.ToString(),
                   AccountHolder = Bal.ElementAt(1).Account.AccountHolder,
                   CAB = Bal.ElementAt(1).Account.CAB,
                   CurrencyBookingBalance = Bal.ElementAt(1).CurrencyBookingBalance
               });
               context.Transactions.Add(new Transaction_Model()
               {
                   ABI = tra.ElementAt(1).Account.ABI,
                   AccountDescription = tra.ElementAt(1).Account.Description,
                   Amount = tra.ElementAt(1).Amount,
                   TransactionDate = tra.ElementAt(1).TransactionDate.ToString(),
                   AdditionalDescription = tra.ElementAt(1).AdditionalDescription.ToString(),
                   AccountHolder = tra.ElementAt(1).Account.AccountHolder,
                   CAB = tra.ElementAt(1).Account.CAB,
                   Currency = tra.ElementAt(1).Currency,
                   Description = tra.ElementAt(1).Description,
                   Id = tra.ElementAt(1).Id,
                   Number = tra.ElementAt(1).Account.Number.ToString(),
                   ValueDate = tra.ElementAt(1).ValueDate.ToString(),
                   AbiReason = tra.ElementAt(1).AbiReason
               });
               base.Seed(context);
           }
       }

AnswerRe: Storing deserialized data into SQL Server Ce using Entity Framework code first Pin
Dave Kreskowiak11-Apr-14 6:59
mveDave Kreskowiak11-Apr-14 6:59 
QuestionToolStripMenuItem color becomes white after clicking Pin
Aaditya Hasiyan10-Apr-14 21:38
Aaditya Hasiyan10-Apr-14 21:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.