Minor Changes and BugFix to EF Querys
This commit is contained in:
parent
7c24cf009b
commit
c12615bc1b
@ -211,9 +211,7 @@
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="DTO\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
|
@ -13,6 +13,8 @@ namespace LoggingClient.Repository
|
||||
}
|
||||
public List<Customer> Customers { get; set; }
|
||||
|
||||
public string TableName => throw new NotImplementedException();
|
||||
|
||||
public void Add(Customer newCustomerEntry)
|
||||
{
|
||||
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)
|
||||
{
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
|
@ -6,29 +6,30 @@ using System.Linq;
|
||||
|
||||
namespace LoggingClient.Repository
|
||||
{
|
||||
public class CustomerRepositoryLinq
|
||||
public class CustomerRepositoryLinq : IRepositoryBase<Customer>
|
||||
{
|
||||
inventarisierungsloesungEntities _dataContext;
|
||||
public CustomerRepositoryLinq()
|
||||
{
|
||||
_dataContext = new inventarisierungsloesungEntities();
|
||||
}
|
||||
public CustomerRepositoryLinq() { }
|
||||
|
||||
public string TableName => throw new NotImplementedException();
|
||||
|
||||
public void Add(Customer entity)
|
||||
{
|
||||
var customer = new Customer()
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
{
|
||||
firstname = entity.firstname,
|
||||
lastname = entity.lastname,
|
||||
customernumber = entity.customernumber,
|
||||
kundenkonto_fk = entity.kundenkonto_fk,
|
||||
tel = entity.tel,
|
||||
email = entity.email,
|
||||
url = entity.url,
|
||||
password = entity.password
|
||||
};
|
||||
_dataContext.Customer.Add(customer);
|
||||
_dataContext.SaveChanges();
|
||||
var customer = new Customer()
|
||||
{
|
||||
firstname = entity.firstname,
|
||||
lastname = entity.lastname,
|
||||
customernumber = entity.customernumber,
|
||||
kundenkonto_fk = entity.kundenkonto_fk,
|
||||
tel = entity.tel,
|
||||
email = entity.email,
|
||||
url = entity.url,
|
||||
password = entity.password
|
||||
};
|
||||
context.Customer.Add(customer);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void CallStoredProcedure(Customer entity)
|
||||
@ -36,13 +37,26 @@ namespace LoggingClient.Repository
|
||||
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)
|
||||
{
|
||||
var x = (from c in _dataContext.Customer
|
||||
where (c.customer_id == entity.customer_id)
|
||||
select c).SingleOrDefault();
|
||||
_dataContext.Customer.Remove(x);
|
||||
_dataContext.SaveChanges();
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
{
|
||||
var x = (from c in context.Customer
|
||||
where (c.customer_id == entity.customer_id)
|
||||
select c).SingleOrDefault();
|
||||
context.Customer.Remove(x);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Customer> GetAll(string whereCondition, Dictionary<string, object> parameterValues)
|
||||
@ -52,7 +66,10 @@ namespace LoggingClient.Repository
|
||||
|
||||
public IQueryable<Customer> GetAll()
|
||||
{
|
||||
return _dataContext.Customer.AsQueryable();
|
||||
using (var context = new inventarisierungsloesungEntities())
|
||||
{
|
||||
return context.Customer.AsQueryable();
|
||||
}
|
||||
}
|
||||
|
||||
public Customer GetSingle<P>(P pkValue)
|
||||
@ -64,5 +81,10 @@ namespace LoggingClient.Repository
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
List<Customer> IRepositoryBase<Customer>.GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ namespace LoggingClient.Repository
|
||||
{
|
||||
try
|
||||
{
|
||||
location.AddressId = 2;
|
||||
using (var conn = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
@ -199,7 +199,7 @@ namespace LoggingClient.ViewModel
|
||||
try
|
||||
{
|
||||
var customerModelRepositoryEF = new CustomerRepositoryEF();
|
||||
customerModelRepositoryEF.Add(SelectedItem);
|
||||
customerModelRepositoryEF.Add(MySelectedItem);
|
||||
Customers = customerModelRepositoryEF.GetAll();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
0
dbTestat/ERM.pdf
Executable file → Normal file
0
dbTestat/ERM.pdf
Executable file → Normal file
0
dbTestat/inventarisierungsloesung.bak
Executable file → Normal file
0
dbTestat/inventarisierungsloesung.bak
Executable file → Normal file
Loading…
Reference in New Issue
Block a user