Minor Changes and BugFix to EF Querys

This commit is contained in:
francesco 2020-08-18 20:58:21 +02:00
parent 7c24cf009b
commit c12615bc1b
7 changed files with 60 additions and 29 deletions

View File

@ -211,9 +211,7 @@
<ItemGroup> <ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="DTO\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<WCFMetadata Include="Connected Services\" /> <WCFMetadata Include="Connected Services\" />
</ItemGroup> </ItemGroup>

View File

@ -13,6 +13,8 @@ namespace LoggingClient.Repository
} }
public List<Customer> Customers { get; set; } public List<Customer> Customers { get; set; }
public string TableName => throw new NotImplementedException();
public void Add(Customer newCustomerEntry) public void Add(Customer newCustomerEntry)
{ {
using (var context = new inventarisierungsloesungEntities()) using (var context = new inventarisierungsloesungEntities())
@ -33,6 +35,16 @@ namespace LoggingClient.Repository
} }
} }
public long Count(string whereCondition, Dictionary<string, object> parameterValues)
{
throw new NotImplementedException();
}
public long Count()
{
throw new NotImplementedException();
}
public void Delete(Customer entity) public void Delete(Customer entity)
{ {
using (var context = new inventarisierungsloesungEntities()) using (var context = new inventarisierungsloesungEntities())

View File

@ -6,15 +6,15 @@ using System.Linq;
namespace LoggingClient.Repository namespace LoggingClient.Repository
{ {
public class CustomerRepositoryLinq public class CustomerRepositoryLinq : IRepositoryBase<Customer>
{ {
inventarisierungsloesungEntities _dataContext; public CustomerRepositoryLinq() { }
public CustomerRepositoryLinq()
{ public string TableName => throw new NotImplementedException();
_dataContext = new inventarisierungsloesungEntities();
}
public void Add(Customer entity) public void Add(Customer entity)
{
using (var context = new inventarisierungsloesungEntities())
{ {
var customer = new Customer() var customer = new Customer()
{ {
@ -27,8 +27,9 @@ namespace LoggingClient.Repository
url = entity.url, url = entity.url,
password = entity.password password = entity.password
}; };
_dataContext.Customer.Add(customer); context.Customer.Add(customer);
_dataContext.SaveChanges(); context.SaveChanges();
}
} }
public void CallStoredProcedure(Customer entity) public void CallStoredProcedure(Customer entity)
@ -36,13 +37,26 @@ namespace LoggingClient.Repository
throw new NotImplementedException(); throw new NotImplementedException();
} }
public long Count(string whereCondition, Dictionary<string, object> parameterValues)
{
throw new NotImplementedException();
}
public long Count()
{
throw new NotImplementedException();
}
public void Delete(Customer entity) public void Delete(Customer entity)
{ {
var x = (from c in _dataContext.Customer using (var context = new inventarisierungsloesungEntities())
{
var x = (from c in context.Customer
where (c.customer_id == entity.customer_id) where (c.customer_id == entity.customer_id)
select c).SingleOrDefault(); select c).SingleOrDefault();
_dataContext.Customer.Remove(x); context.Customer.Remove(x);
_dataContext.SaveChanges(); context.SaveChanges();
}
} }
public List<Customer> GetAll(string whereCondition, Dictionary<string, object> parameterValues) public List<Customer> GetAll(string whereCondition, Dictionary<string, object> parameterValues)
@ -52,7 +66,10 @@ namespace LoggingClient.Repository
public IQueryable<Customer> GetAll() public IQueryable<Customer> GetAll()
{ {
return _dataContext.Customer.AsQueryable(); using (var context = new inventarisierungsloesungEntities())
{
return context.Customer.AsQueryable();
}
} }
public Customer GetSingle<P>(P pkValue) public Customer GetSingle<P>(P pkValue)
@ -64,5 +81,10 @@ namespace LoggingClient.Repository
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
List<Customer> IRepositoryBase<Customer>.GetAll()
{
throw new NotImplementedException();
}
} }
} }

View File

@ -23,7 +23,6 @@ namespace LoggingClient.Repository
{ {
try try
{ {
location.AddressId = 2;
using (var conn = new MySqlConnection(ConnectionString)) using (var conn = new MySqlConnection(ConnectionString))
{ {
conn.Open(); conn.Open();

View File

@ -199,7 +199,7 @@ namespace LoggingClient.ViewModel
try try
{ {
var customerModelRepositoryEF = new CustomerRepositoryEF(); var customerModelRepositoryEF = new CustomerRepositoryEF();
customerModelRepositoryEF.Add(SelectedItem); customerModelRepositoryEF.Add(MySelectedItem);
Customers = customerModelRepositoryEF.GetAll(); Customers = customerModelRepositoryEF.GetAll();
} }
catch (Exception ex) catch (Exception ex)

0
dbTestat/ERM.pdf Executable file → Normal file
View File

0
dbTestat/inventarisierungsloesung.bak Executable file → Normal file
View File