ServiceStack ORMLite and Dapper Working together Issues
Tag : chash , By : greggerz
Date : March 29 2020, 07:55 AM
Does that help It seems to be easier to just override the abstract Id on every class instead of modifying ORMLite's source code. The project's schedule is narrow to try another approach. Perhaps for the next one I can find the time to try what @mithz kindly suggests.
|
ServiceStack ORMLite Caching error
Tag : chash , By : Kilimanjaro
Date : March 29 2020, 07:55 AM
should help you out Your cache population delegate function must return a result of T, as the last argument of ToOptimzedResultUsingCache is System.Func. As you have not specified T and you have no return it won't compile. Try specifying the type of T as Patient and setting the return as shown below:var cacheKey = request.SSN;
var expireInTimespan = new TimeSpan(0, 0, 15, 0);
return base.Request.ToOptimizedResultUsingCache<Patient>(base.Cache, cacheKey, expireInTimespan, () => {
var patient = dbConn.Single<Patient>(x => x.SSN == request.SSN && x.FacilityLocationId == Convert.ToInt32(UALocation));
if(patient == null)
return null;
dbConn.LoadReferences(patient);
...
return patient;
});
|
Save data from grid using Dapper.net and ServiceStack.OrmLite
Tag : vb.net , By : Enrique Anaya
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I'm having hard time following your code but dapper syntax for insert should be like this: using (var conn = new SqlConnection("YourConnString"))
{
return conn.Execute(query, instaceToInsert);
}
INSERT INTO Users (LastName, FirstName) VALUES (@LastName, @FirstName)
public class User
{
public string LastName { get; set; }
public string FirstName { get; set; }
}
using (var conn = new SqlConnection("YourConnString"))
{
return conn.Execute(query, new User {LastName = "John", FirstName = "Doe"});
}
Using conn = New SqlConnection("YourConnString")
Return conn.Execute(query, instaceToInsert)
End Using
Public Class User
Public Property LastName() As String
Public Property FirstName() As String
End Class
Using conn = New SqlConnection("YourConnString")
Return conn.Execute(query, New User() With { .LastName = "John", .FirstName = "Doe"})
End Using
|
Why does ServiceStack OrmLite crash with null exception when I add OrmLite.Firebird?
Date : March 29 2020, 07:55 AM
I hope this helps you . You can't mix and match different versions of ServiceStack libraries together. This error suggests that it's still trying to load older v4.0.11 of ServiceStack:
|
How make mapping in serviceStack.ormlite or Dapper dependent on column type?
Tag : chash , By : Jason Jennings
Date : March 29 2020, 07:55 AM
I wish this help you You're expecting a bit much of Dapper I feel. It's not Dapper's job to do this. But instead of writing your own factories, why don't you introduce a DI container. With TinyIoC for example, you would register B and C as named implementations of interface A. When another DeviceType comes along, you just register a new implementation and you're in business. public interface A
{
POCO poco { get; set; }
void MyMethod();
}
public class B : A
{
public void MyMethod()
{
throw new NotImplementedException();
}
public POCO poco { get; set; }
}
public class C : A
{
public void MyMethod()
{
throw new NotImplementedException();
}
public POCO poco { get; set; }
}
public class POCO
{
public ulong? id { get; set; }
public string Name { get; set; }
public string DeviceType { get; set; }
}
public class Program
{
public static void main()
{
var ctr = TinyIoCContainer.Current;
ctr.Register<A, B>("B");
ctr.Register<A, C>("C");
List<A> devices = new List<A>();
using (var db = new SqlConnection(Config.DefaultConnectionString))
{
db.Open();
List<POCO> queryResults = db.Query<POCO>("SELECT * FROM Devices").ToList();
foreach (var queryResult in queryResults)
{
// the magic step where we create the right type of A based on the value in column Name...
var newDevice = ctr.Resolve<A>(queryResult.Name);
newDevice.poco = queryResult;
devices.Add(newDevice);
}
}
}
}
|