entity-framework

Implement data validation in entity framework code first

扶醉桌前 提交于 2021-01-28 19:49:26
问题 I am using entity framework 6, .Net framework 4 and code first. I am able to get the validation errors by using GetValidationResult method. But I was not able to show the validation message like the one given in the below image. How to achieve this? My Code: <Label Content="Name" /> <Grid Grid.Row="0" Grid.Column="2"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <TextBox x:Name="txtName" Width="200" Margin="8,0,0,0" MaxLength="150" Text="{Binding Path

Entity framework Select first item in group that satisfies condition or just first item

眉间皱痕 提交于 2021-01-28 14:38:07
问题 I have a table with localized values like this LocalizedFruits ID | LOCALE | NAME 1 | en_UK | Banana 2 | da_DK | Banan 3 | de_DE | Banane 4 | zh-CHS | 香蕉 Then i want to autocomplete the value the user is typing, if the user is chinese it's all good but if it's people from one of the other cultures a problem arises, when they type "ba" the user will get 3 results that are the same thing. therefore i group the result by Locale. What i want to do is i want to get the group with the same locale

Entity framework Select first item in group that satisfies condition or just first item

怎甘沉沦 提交于 2021-01-28 14:34:13
问题 I have a table with localized values like this LocalizedFruits ID | LOCALE | NAME 1 | en_UK | Banana 2 | da_DK | Banan 3 | de_DE | Banane 4 | zh-CHS | 香蕉 Then i want to autocomplete the value the user is typing, if the user is chinese it's all good but if it's people from one of the other cultures a problem arises, when they type "ba" the user will get 3 results that are the same thing. therefore i group the result by Locale. What i want to do is i want to get the group with the same locale

Build Expression tree for LINQ to Entities Where clause

心已入冬 提交于 2021-01-28 14:13:55
问题 I want to be able to write the following code for a LINQ to Entities query (EF6) Repo.ContactRelations.WhereActive() .Select(r => new ContactModel { Id = r.Contact.Id, FirstName = r.Contact.FirstName, LastName = r.Contact.Surname, WorkEmail = r.Contact.WorkEmail }) Without the WhereActive() method, I would have to repeat the following expression in numerous places: Repo.ContactRelations.Where(c => c.EndDate == null || c.EndDate > DateTime.Today) I tried to write a simple extension method, but

Table 'dbname.dbname.tablename' doesn't exists error in Visual Studio when adding Mysql Entity Framework

北慕城南 提交于 2021-01-28 12:44:51
问题 I am trying to add MySQL with Entity Framework in Visual Studio. I am using MySQL Server 8.0.12 and also the 8.0.12 Connector/MySql.data. error: MysqlException: Table 'dbname.dbname.tablename' doesn't exists. Normally I have table but dbname name showing twice. My code's very simple, I want to list all datas in my table: using (sakilaEntities db = new sakilaEntities()) { var list = db.country.ToList(); } I'm getting below error. UPDATE: Uninstall MySQL Server 8.0.12 and MySQL Connector 8.0.12

Table 'dbname.dbname.tablename' doesn't exists error in Visual Studio when adding Mysql Entity Framework

こ雲淡風輕ζ 提交于 2021-01-28 12:44:41
问题 I am trying to add MySQL with Entity Framework in Visual Studio. I am using MySQL Server 8.0.12 and also the 8.0.12 Connector/MySql.data. error: MysqlException: Table 'dbname.dbname.tablename' doesn't exists. Normally I have table but dbname name showing twice. My code's very simple, I want to list all datas in my table: using (sakilaEntities db = new sakilaEntities()) { var list = db.country.ToList(); } I'm getting below error. UPDATE: Uninstall MySQL Server 8.0.12 and MySQL Connector 8.0.12

Delegate System.Action<dynamic,int> does not take `1' arguments

爷,独闯天下 提交于 2021-01-28 12:20:18
问题 I am trying to build the PostgreSqlGeneration code from this repository on Mono. Unfortunately I get an error I do not understand. In the PostgreSqlMigrationSqlGenerator class the following method gives the build error "delegate System.Action does not take `1' arguments": private void GenerateStatements(IEnumerable<MigrationOperation> migrationOperations) { Check.NotNull(migrationOperations, "migrationOperations"); DetectHistoryRebuild(migrationOperations).Each<dynamic>(o => Generate(o)); //

ADO.NET is missing even after the installation

岁酱吖の 提交于 2021-01-28 12:07:28
问题 I've just installed the ADO.NET entity but I'm still missing the model in New Project. I made a research around the web and I found several solutions that didn't help me a lot. I tried to reinstall the Entity Framework, to add (in my case update) the assemblies from the project, to install the "EFTools.msi" from "C:\ProgramData\Package Cache". Any ideas what's going on? I'm using Visual Studio 2013 from DreamSpark. 回答1: The entity Framework Model is a file item, not a project. So create a

Filtering a binding list, binding doesn't work

萝らか妹 提交于 2021-01-28 11:53:16
问题 In a grid i use a binding list to bind data: childBindingSource.DataSource = db.Child.Local.ToBindingList() .Where(child => selectedrow != null && child.MasterID == selectedrow.ID) .ToList(); Or without filter: childBindingSource.DataSource = db.Child.Local.ToBindingList(); If I filter the binding list using a where expression, saving data doesn't work,yet i do not get any exceptions. Any ideas? Row click event for getting child records: private void gridView1_RowClick(object sender,

How to fix System.Data.SqlClient.SqlException : “Login failed for user ”xx\xxxx$“”

坚强是说给别人听的谎言 提交于 2021-01-28 09:13:10
问题 I ran a web app on IIS and I got a System.Data.SqlClient.SqlException: "Login failed for user'domain\account$'". This is a exception when the function DbMigrator.Update() is called private readonly DbMigrationsConfiguration<MyContext> _config; public ContextInitializer(string connectionString) { _config = new Configuration() { TargetDatabase = new DbConnectionInfo(connectionString, "System.Data.SqlClient") }; } ... public void InitializeDatabase(MgmtStudioContext context) { var migrator = new